角度异常:无法绑定到’ngFor’,因为它不是已知的本机属性

前端之家收集整理的这篇文章主要介绍了角度异常:无法绑定到’ngFor’,因为它不是已知的本机属性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我究竟做错了什么?
  1. import {bootstrap,Component} from 'angular2/angular2'
  2.  
  3. @Component({
  4. selector: 'conf-talks',template: `<div *ngFor="talk of talks">
  5. {{talk.title}} by {{talk.speaker}}
  6. <p>{{talk.description}}
  7. </div>`
  8. })
  9. class ConfTalks {
  10. talks = [ {title: 't1',speaker: 'Brian',description: 'talk 1'},{title: 't2',speaker: 'Julie',description: 'talk 2'}];
  11. }
  12. @Component({
  13. selector: 'my-app',directives: [ConfTalks],template: '<conf-talks></conf-talks>'
  14. })
  15. class App {}
  16. bootstrap(App,[])

错误

  1. EXCEPTION: Template parse errors:
  2. Can't bind to 'ngFor' since it isn't a known native property
  3. ("<div [ERROR ->]*ngFor="talk of talks">
在谈话前我错过了:
  1. <div *ngFor="let talk of talks">

请注意,不推荐使用#…来在结构指令(如NgFor)中声明局部变量。请改用let。
< div * ngFor =“#talk of talks”>现在变成< div * ngFor =“让谈谈谈话”>

原始答案:

我在谈话前错过了#:

  1. <div *ngFor="#talk of talks">

很容易忘记#。我希望Angular异常错误消息会改为:你再次忘记了#。

猜你在找的Angularjs相关文章