How to load page after array is filled? How to load page after array is filled? typescript typescript

How to load page after array is filled?


Justuse this

<div><span>Name: </span>{{item?.name}}</div>

OR

<div *ngIf="item"><span>Name: </span>{{item.name}}</div>


Try adding a check before displaying it in the UI.

<div *ngIf="item"><span>Name: </span>{{item.name}}</div>

And so the item.name wont be evaluated until there is value in item.


As the error is self-explanatory, it is trying to render the view even before the data is available. You can add the defensive condition to resolve this. Something like *ngIf="item && item.name".Hope it helps!