简体   繁体   中英

Angular 2 RC5: Can't bind to 'ngFor' since it isn't a known property of

After upgrading to RC5, I suddenly got this error:

Can't bind to 'ngFor' since it isn't a known property of 'div'. ("

<div [ERROR ->]*ngFor="t of test">{{t}}</div>")

The HTML:

<div *ngFor="t of test">asdas</div>

All posts on this topic explain that you need to import BrowserModule, but I already did that.

After banging my head against the wall, I found the solution: I had forgotten the word "let" in front of my variable!

Pre RC5 this used to work, so this is a breaking change in RC5. I know let is required, but previously this just worked. And the error is not helpful at all.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM