gpt4 book ai didi

Angular2 模板解析错误 : Property binding ngFor not used by any directive on an embedded template

转载 作者:太空狗 更新时间:2023-10-29 18:00:00 25 4
gpt4 key购买 nike

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

最佳答案

尝试一下可能会有帮助

  <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>

关于Angular2 模板解析错误 : Property binding ngFor not used by any directive on an embedded template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37221231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com