【发布时间】:2022-08-09 15:39:17
【问题描述】:
我想将ion-select 值重置为空。选择后我正在导航到另一个页面,当我从该页面单击后退按钮时,ion-select 选择了该值。我希望它重置后退按钮上的离子选择。
这是我的 .html 文件代码
<ion-select #mySelect style=\"display: none\" (ionChange)=\"onOrderSelection($event)\" interface=\"action-sheet\" mode=\"ios\" [value]=\"orderTypeModel\">
<ion-select-option *ngFor=\"let item of orderTypes\" [value]=\"item.id\">{{ item.name }}</ion-select-option>
</ion-select>
这是组件代码
orderTypeModel = \'\';
ionViewWillEnter(): void {
this.orderTypeModel = null;
this.changeDetecRef.detectChanges();
}
我也尝试过用[ngModel] 代替[value],但该事件不起作用。
请建议一些方法来做到这一点?
-
您的代码适用于
[value]和[(ngModel)]。 -
你能创建一个stackblitz吗?
标签: javascript angular ionic-framework ionic6