Angular2模板解析错误:嵌入模板上的任何指令都未使用属性绑定ngFor



这是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"

国家变量定义为:

public countries: Array<Country> = [];

我使用ngFor有什么问题?为什么它在寻找ngForCountry?

Just try might help

  <paper-dropdown-menu label="Country">
    <paper-listbox class="dropdown-content" [(ngModel)]="selectedCountry" (ngModelChange)="GetAdmin1s($event)">
        <paper-item ngFor #country [ngForOf]="countries" value="{{country.Id}}">{{country.Name}}</paper-item>
    </paper-listbox>
  </paper-dropdown-menu>

您可以尝试:*ngFor="#国家/地区"

相关内容

最新更新