【发布时间】:2016-05-14 13:52:45
【问题描述】:
这是 Angular2 模板:
<paper-dropdown-menu label="Country">
<paper-listbox class="dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
<paper-item *ngFor="let country of countries" value="{{country.Id}}">{{country.Name}}</paper-item>
</paper-listbox>
</paper-dropdown-menu>
我收到此错误:
"Template parse errors:
Property binding ngFor not used by any directive on an embedded template (""dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
[ERROR ->]<paper-item *ngFor="let country of countries" value="{{country.Id}}">{{country.Name}}</paper-item>
"): LocationComponent@4:12
Property binding ngForCountry not used by any directive on an embedded template (""dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
[ERROR ->]<paper-item *ngFor="let country of countries" value="{{country.Id}}">{{country.Name}}</paper-item>
"): LocationComponent@4:12"
Countries 变量定义为:
public countries: Array<Country> = [];
我使用 ngFor 有什么问题?为什么要寻找 ngForCountry?
【问题讨论】:
-
你确定你在运行 angular2 >= beta-17?
-
请发一个 plunkr,I'm unable to reproduce this(请随意分叉)
-
我刚刚升级到 rc.1,但仍然出现错误。我正在尝试使用所涉及的所有依赖项进行 plunkr。