Why can't var be used instead of let in ngFor

Viewed 1975

As per my knowledge we use var and let for variable declarations in javascript, the only difference being that var gets scoped to the current function, while let gets scoped to the current block. So it should work if I use var instead of let anywhere. But in the below code...

<li *ngFor="let fruit of fruits">
   {{ fruit}}
</li>

...if I use var it gives an error.

<li *ngFor="var fruit of fruits">
   {{ fruit}}
</li>

Error: Uncaught (in promise): Error: Template parse errors: Parser Error: Unexpected token var at column 1 in [var fruit of fruits] in ng:///AppModule/AppComponent.html@4:4 ("

Can someone tell me why this occurs?

2 Answers
Related