如何解决除非单击,ion-select内的字符串不会改变
我要实现的是,当我触发方法"onUpdateMeasure($event)"
来自动更新{{unit}}
时。完成我的工作(部分工作)后,它会更新{{unit}}
值,但前提是您单击选择(带有占位符“ placeholder="My Goal"
”的选择。我要实现的是单击“首先选择并触发"onUpdateMeasure($event)"
,自动更新第二次离子选择中的{{unit}}
,不仅在单击时也是如此。如果你们有什么想法,我将非常感谢
HTML
<ion-select
[interfaceOptions]="customInterfaceOptions"
interface="action-sheet"
formControlName="measure"
(ionChange)="onUpdateMeasure($event)"
<ion-select-option value="k">k</ion-select-option>
<ion-select-option value="l">l</ion-select-option>
</ion-select>
<ion-select
[interfaceOptions]="customInterfaceOptions"
interface="action-sheet"
formControlName="unit"
placeholder="My Goal">
<ion-select-option value="l02">{{unit}} per week</ion-select-option>
<ion-select-option value="l1"> {{unit}} per week </ion-select-option>
</ion-select>
TS
onUpdateMeasure(e) {
let selection = e.detail.value;
if (selectiont === "k") {
this.unit = "kg";
} else if (selectionWeight == "l") {
this.unit = "lbs";
}
}
解决方法
我已经更新了您的代码,希望对您有用。
HTML
<ion-select [interfaceOptions]="customInterfaceOptions"
interface="action-sheet" (ionChange)="onUpdateMeasure($event)">
<ion-select-option value="k">k</ion-select-option>
<ion-select-option value="l">l</ion-select-option>
</ion-select>
<ion-select [interfaceOptions]="customInterfaceOptions"
interface="action-sheet" placeholder="My Goal" [(ngModel)]='unit'>
<ion-select-option [value]='unit'>{{unit}} per week</ion-select-option>
</ion-select>
TS
onUpdateMeasure(e) {
let selection = e.detail.value;
if (selection === "k") {
this.unit = "kg";
}
else if (selection == "l") {
this.unit = "lbs";
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。