Amaro Barros
Amaro Barros

Reputation: 53

Cannot read property 'toUpperCase' of undefined with the ERROR on *ngFor

I am trying to declare an index in *ngFor but I am getting a type error and it is saying

<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: 5

Views: 6761

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 658155

It pipe should come before the index

<div class='text' *ngFor='let item of blogs | async | filter : 'feat' : true'; let i = index >

Upvotes: 12

Related Questions