angular – On IONIC Ion-Select正在“选择”所有选项

前端之家收集整理的这篇文章主要介绍了angular – On IONIC Ion-Select正在“选择”所有选项前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的Ionic应用程序中,我有一个离子选择:

<ion-item>
  <ion-label>Type</ion-label>

  <ion-select [(ngModel)]="type" interface="action-sheet">
      <ion-option *ngFor="let type of types" 
                  value="type.class">
                  {{type.name}}
      </ion-option>
  </ion-select>
</ion-item>

每当我选择一个选项时,它会选择所有可用的选项.
我alredy尝试使用属性multiple =“false”但没有奏效.

额外细节:

type.class is the same value for every option. I already put diferent values for each option. None worked.
If I totally remove the value=”” it work properly

有帮助吗?

解决方法

由于您的值赋值是动态的,您需要在值周围使用[],

<ion-option *ngFor="let type of types" [value]="type.class">
  {{type.name}}
</ion-option>

希望能帮助到你.

猜你在找的Angularjs相关文章