1
我已搜索此here和here。我使用的2.0.0-beta.7版2角,但它給我的錯誤是這樣的:EXCEPTION:模板解析錯誤:無法綁定到'ngForFrom',因爲它不是已知的本地屬性
EXCEPTION: Template parse errors:
Can't bind to 'ngForFrom' since it isn't a known native property ("<h2>list of fruits</h2>
<ul>
<li [ERROR ->]*ngFor="#item from itemList">{{item.name}}</li>
</ul>"): [email protected]:4
Property binding ngForFrom not used by any directive on an embedded template ("<h2>list of fruits</h2>
<ul>
按照
知道它是用駱駝外殼,但它不是爲我工作。
這裏是我的.ts文件:
import {Component} from "angular2/core";
@Component({
selector:'my-list'
template:`<h2>list of fruits</h2>
<ul>
<li *ngFor="#item from itemList">{{item.name}}</li>
</ul>`
})
export class ItemComponent{
public itemList=[
{name:"Apple"},
{name:"Orange"},
{name:"Grapes"}
];
}
將itemite項目中的#item改爲itemList項目的#item。 – yurzui
嘗試使用'* ngFor =「let itemList」'。 –
@Lenilson de Castro似乎他使用的是舊版本,所以'let'不會工作 – yurzui