Amir Pashazadeh
Amir Pashazadeh

Reputation: 7322

The # (hash) does not work in angular 2 templates

I'm new to Angular 2. As I read through Angular 2 tutorials on the web, the # (hash) is used to declare local variables in the template. But every time I use #, the parser throws some parsing exceptions.

For example if I use <div *ngFor="#item of items"> following exception happnes, but if I use let instead of # everything goes fine.

Unhandled Promise Rejection: Template Parse Error:
Parse Error: Unexpected token # at column ....

Do I miss some configuration for Angular 2 parser?

P.S. By the way I'm using Angular 2 2.5.x.

Upvotes: 0

Views: 197

Answers (1)

Igor Janković
Igor Janković

Reputation: 5532

It's an old syntax. That was the syntax in angular 2 beta releases. Now, it is different.

<div *ngFor="let item of items">

Upvotes: 4

Related Questions