What is the difference between [ngFor] and [ngForOf] in angular2?

前端 未结 5 415
南笙
南笙 2020-12-05 13:02

As per my understanding, Both are doing the same functions. But,

  • ngFor would be works like as collections?.

  • ngFo

5条回答
  •  执笔经年
    2020-12-05 13:26

    NgFor can iterate an array but in ngContainer, ngContent we cannot iterate ngFor directly so For iterating we can use [ngForOf] . Here i is variable, ratings is an array.

    Ex.

     
                      
       
    

    At this example, I want to apply a ngFor and ngIf simultaneously, so i used it.

    The other view is that at a normal if we apply ngFor then at rendering it converts it into

    
    

提交回复
热议问题