Angular2模板解析错误:属性绑定ng对于嵌入式模板上的任何指令都不使用

前端之家收集整理的这篇文章主要介绍了Angular2模板解析错误:属性绑定ng对于嵌入式模板上的任何指令都不使用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是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?

解决方法

@H_404_30@ 试试可能有帮助

<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>
原文链接:https://www.f2er.com/angularjs/633896.html

猜你在找的Angularjs相关文章