Reputation: 579
I am trying to declare an index in *ngFor but I am getting a type error and it is saying
Cannot read property 'toUpperCase' of undefined with the ERROR on *ngFor
<div class="text" *ngFor="let item of blogs; let i = index | async | filter : 'feat' : true">
If I take out let i = index it works fine, but I want to use the index, so I can apply css classes to the elements. Looking at documentation, this is how you are supposed to do it.
Upvotes: 0
Views: 763
Reputation: 657308
index
is maintained by ngFor
and exported as index
. All you can do is to define a name of a template variable you want to access that index with. You can't apply pipes or calculations to that assignment.
Upvotes: 1
Reputation: 8073
It should be
<div class="text" *ngFor="let item of blogs | async | filter : 'feat' : true; let i = index">
Upvotes: 1