Angular exception: Can't bind to 'ngForIn' since it isn't a known native property

前端 未结 9 2353
说谎
说谎 2020-11-30 21:15

What am I doing wrong?

import {bootstrap, Component} from \'angular2/angular2\'

@Component({
  selector: \'conf-talks         


        
9条回答
  •  长情又很酷
    2020-11-30 21:21

    TL;DR;

    Use let...of instead of let...in !!


    If you're new to Angular (>2.x) and possibly migrating from Angular1.x, most likely you're confusing in with of. As andreas has mentioned in the comments below for ... of iterates over values of an object while for ... in iterates over properties in an object. This is a new feature introduced in ES2015.

    Simply replace:

    
    

    with

    
    

    So, you must replace in with of inside ngFor directive to get the values.

提交回复
热议问题