我在做什麼錯了?角度異常:無法綁定到'ngFor',因爲它不是已知的本地屬性
import {bootstrap, Component} from 'angular2/angular2'
@Component({
selector: 'conf-talks',
template: `<div *ngFor="talk of talks">
{{talk.title}} by {{talk.speaker}}
<p>{{talk.description}}
</div>`
})
class ConfTalks {
talks = [ {title: 't1', speaker: 'Brian', description: 'talk 1'},
{title: 't2', speaker: 'Julie', description: 'talk 2'}];
}
@Component({
selector: 'my-app',
directives: [ConfTalks],
template: '<conf-talks></conf-talks>'
})
class App {}
bootstrap(App, [])
的錯誤是
EXCEPTION: Template parse errors:
Can't bind to 'ngFor' since it isn't a known native property
("<div [ERROR ->]*ngFor="talk of talks">
究竟是什麼&符號?我解決了我自己的問題,但我不確定這是甚麼。 –
@datatype_void,散列('#')用於聲明[本地模板變量](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#local-vars) –
我嘗試使用「let」語法而不是#它生成「無法綁定到'ngFor',因爲它不是已知的本地屬性」。與您在原始問題中看到的行爲相同。我將它改回#並且它似乎沒有任何問題。我正在使用angular2.0.0-rc.1,並且我也使用angular2.0.0-beta.17 – Chadley08