Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 render template after the PROMISE with data is loaded

Tags:

angular

I'm new to AngularJS 2.0, basically I'm loading data through Promise in constructor, but the template is rendered before the promise is resolved.

Any idea how to achieve this?

Thanks, M.

like image 423
Milan Klíma Avatar asked Oct 14 '15 22:10

Milan Klíma


1 Answers

You can test the data before using it.

<ul *ngIf="data">
  <li *ngFor="let item of data">{{item.value}}</li>
</ul>
like image 81
yang lin Avatar answered Oct 04 '22 04:10

yang lin