typescript Angularjs 2:在 ion-select Ionic 2 中选择不更新选定的值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35685214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Angularjs 2: select not updating with selected value in ion-select Ionic 2?
提问by happycoder
I have below code which is working so far, but have small problem which I cannot figure it out. It's not updating (set the selected value into ion-select) ion-select after user chooses one option? Basically UI is not updating with selected value?
到目前为止,我有以下代码,但有一些小问题,我无法弄清楚。用户选择一个选项后,它不会更新(将所选值设置为 ion-select) ion-select ?基本上 UI 没有用选定的值更新?
<ion-item>
<ion-label>Classifications</ion-label>
<ion-select [(ngModel)]="selectedItem" #item (change)="onChange(selectedItem)">
<ion-option *ngFor="#item of items" [value]="item">{{item}}</ion-option>
</ion-select>
</ion-item>
onChange(selectedItem) {
console.log('Selected item: '+selectedItem);
}
Out put properly displays as user select, any ideas what I'm missing here?
输出正确显示为用户选择,任何想法我在这里缺少什么?
update
更新
<ion-item>
<ion-label>Gender</ion-label>
<ion-select [(ngModel)]="gender">
<ion-option value="f" checked="true">Female</ion-option>
<ion-option value="m">Male</ion-option>
</ion-select>
</ion-item>
回答by Igor Luzhanov
For Ionic 2 beta 10 next works for me:
对于 Ionic 2 beta 10 下一步对我有用:
<ion-item>
<ion-label>Fest</ion-label>
<ion-select [(ngModel)]="festId" (ionChange)="festSelected($event, festId)">
<ion-option *ngFor="let fest of festList" value="{{fest.id}}">
{{fest.title}}
</ion-option>
</ion-select>
</ion-item>
回答by bhakav
I was having the same issues after adding (ionChange)=""
it started working for me.
添加(ionChange)=""
它开始对我来说有效后,我遇到了同样的问题。
<ion-select [(ngModel)]="msgType" (ionChange)="getListOfMsg()">