angular2 template - Angular 2 *ngFor syntax -


my main issue trying loop number of times let's n, ngfor accepts arrays, like: "#item of [1, 2, ..., n]", proper way loop using item count (without creating useless array has numbers 1 n)?

so started reading more syntax , noticed there are:

  • *ngfor="#item of items;
  • *ngfor="#item in items;

so difference between "in" , "of" , there use cases? , have original case?

thanks in advance.

there no

*ngfor="#item in items; 

you have use of. versions required in changed conform https://developer.mozilla.org/de/docs/web/javascript/reference/statements/for...of

it should be

*ngfor="let item of items; ..." 

currently ngfor iterates on arrays.


Comments