<ion-select (ionChange)="changed($event)">每次更改都会调用两次已更改的方法
预期行为:
每次值更改都应调用一次(ionChange)="changed($event)
注:我已尝试使用tap,单击但没有用
发布于 2019-04-12 12:39:14
我遇到了同样的问题(使用Angular 4,Ionic 3)。在为单个项目列表创建ion-select组件时,我只添加了ion-option子组件的标签,并让框架决定它们的value属性。
当我显式地添加ion-option组件的value属性时,我没有遇到这个问题。
(即)我更改了这个:selector.component.html (旧)
<div>
<ion-select [(ngModel)]="selectedItem"
(ionChange)="change($event)">
<ion-option *ngFor="let item of itemList">{{ item }}</ion-option>
</ion-select>
</div>对此:selector.component.html (现在)
<div>
<ion-select [(ngModel)]="selectedItem"
(ionChange)="change($event)">
<ion-option *ngFor="let item of itemList" [value]="item">{{ item }}</ion-option>
</ion-select>
</div>假设此组件的typescript文件中包含以下内容:
public selectedItem: number = 4;
public itemList: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; // software engineers count from zero ;-)希望这是你的案例,这对你有帮助。干杯..。
https://stackoverflow.com/questions/50143005
复制相似问题