Angular ngFor won';“我不能和”一起工作;让我们;

Angular ngFor won';“我不能和”一起工作;让我们;,angular,Angular,如果我说*ngFor=“#test of data”,我可以获取要在页面上显示的对象,但是如果我说*ngFor=“let test of data”,我得到的无法绑定到'ngFor',因为它不是已知的本机属性 我还是个新手,我不明白为什么它不能输出到屏幕上。感谢您的帮助 forloop.component.ts import {Component} from 'angular2/core' @Component({ selector: 'loop', template: `

如果我说*ngFor=“#test of data”,我可以获取要在页面上显示的对象,但是如果我说*ngFor=“let test of data”,我得到的
无法绑定到'ngFor',因为它不是已知的本机属性
我还是个新手,我不明白为什么它不能输出到屏幕上。感谢您的帮助

forloop.component.ts

import {Component} from 'angular2/core'

@Component({
    selector: 'loop',
    template: `
        <div *ngFor="let test of data">
            {{test.testing}}
        </div>
        `    
})


export class ForLoopComponent{
  data = [
    {
      testing: "1"
      },
    {
      testing: "2"
    },
    {
      testing:"3"    
    }
  ]    
}
import {Component} from 'angular2/core';
import {ForLoopComponent} from './forloop.component';

@Component({
    selector: 'my-app',
    template: '<loop></loop>',
    directives: [ForLoopComponent]
})
export class AppComponent {

}
从'angular2/core'导入{Component}
@组成部分({
选择器:“循环”,
模板:`
{{test.testing}
`    
})
导出类ForLoopComponent{
数据=[
{
测试:“1”
},
{
测试:“2”
},
{
测试:“3”
}
]    
}
app.component.ts

import {Component} from 'angular2/core'

@Component({
    selector: 'loop',
    template: `
        <div *ngFor="let test of data">
            {{test.testing}}
        </div>
        `    
})


export class ForLoopComponent{
  data = [
    {
      testing: "1"
      },
    {
      testing: "2"
    },
    {
      testing:"3"    
    }
  ]    
}
import {Component} from 'angular2/core';
import {ForLoopComponent} from './forloop.component';

@Component({
    selector: 'my-app',
    template: '<loop></loop>',
    directives: [ForLoopComponent]
})
export class AppComponent {

}
从'angular2/core'导入{Component};
从“./forloop.component”导入{ForLoopComponent};
@组成部分({
选择器:“我的应用程序”,
模板:“”,
指令:[ForLoopComponent]
})
导出类AppComponent{
}

您拥有Angular 2的旧版本。在package.json中将其更新为最终版本(2.0.0),然后再次运行npm安装

您可能正在使用旧的Angular 2版本。您使用的是哪个版本?我使用的是angular2种子,我从中学习了angular2种子查看angular.io,您可以在其中找到快速入门