Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NG5002: Cannot parse expression. @for loop expression must match the pattern "<identifier> of <expression>"

after migrating to new angular 17 and updating my template, ng serve throws this message NG5002: Cannot parse expression. @for loop expression must match the pattern " of "

like image 552
Amirreza Avatar asked Jan 22 '26 10:01

Amirreza


2 Answers

New @for syntax doesn't require let:

So for this code: (let item of items; track $item.id), this error will be shown.

Fix is just to use (item of items; track $item.id)..

like image 187
Sasa Jevremovic Avatar answered Jan 25 '26 19:01

Sasa Jevremovic


after some diging, it was because of Capital "O" of "Of"

for some bugs i believe, below line:

@for (relation Of detail.Relations; track relation) {

should be changed to (after auto upgrading by angular tools)

@for (relation of detail.Relations; track relation) {
like image 30
Amirreza Avatar answered Jan 25 '26 18:01

Amirreza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!