I\'m very new to Ionic 2 and i\'ve found myself stuck with an issue. I\'m unable to see the data printing on the page, it throws an error everytime, but I\'m able to see the API
Your md
field is initialized asynchronously in your code. So if the template renders before the response arrives: undefined
.title
will throw an error.
Either initialize your object,
md: any = {};
or use the safe-navigation operator (?
),
{{md?.title}}
or use an *ngIf
to check whether your object is valid or not,
<div *ngIf="md">
{{md.title}}
</div>