[英]ionic2 + Angular2 selection of list
http://ionicframework.com/docs/v2/components/#select http://ionicframework.com/docs/v2/components/#select
I'm trying to show select option and capture the selection. 我正在尝试显示选择选项并捕获选择。 I have tried from method, onChanges and even on putting inline on click, but nothing works.
我已尝试过方法,onChanges甚至在内联点击,但没有任何作用。
<ion-list>
<ion-item>
<ion-label>List </ion-label>
<ion-select [(ngModel)]="selected" multiple="true" cancelText="Cancel" okText="Okay!">
<ion-option *ngFor="#row of list;" value="{{row.id}}" (click)="checkSelected(row.id)" checked="{{ gq.isSelected(row.id) }}">{{ row.english_name }}</ion-option>
</ion-select>
</ion-item>
</ion-list>
Setting page class 设置页面类
export class SettingPage implements OnChanges{
selected;
list = [];
constructor(private nav:NavController, public gq: gq)
{
this.gq
.list()
.subscribe(data => this.list.push(data));
}
stpSelect() {
console.log('STP selected');
console.log(this.selected);
}
ngOnChanges(changes) {
console.log(changes);
}
checkSelected (data)
{
console.log('test');
console.log(data);
}
}
I just want to catch selected model values from a function, when things are changed on it. 我只想从函数中捕获选定的模型值,当它发生变化时。
Since the ion-select component leverages ngModel , you could try to listen to the ngModelChange event: 由于离子选择组件利用ngModel ,您可以尝试侦听ngModelChange事件:
<ion-select [(ngModel)]="selected" multiple="true" cancelText="Cancel" okText="Okay!" (ngModelChange)="doSomething()">
(...)
</ion-select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.