Hi am new to ionic 2 so pls help me. can you give some example for ionchange in ionic 2 for using ion select…Eg. i have 4 option so if i choose one option it ll show the one box, If i choose 2 then it should become the 2…so can you show some program like this.
1 Like
ok let me give you a hint if you don’t need two-way databinding. In your template you can define a select html element as below
<ion-select name="periodSelected" ionChange="onChange($event)" >
<ion-option value="1">Ex1</ion-option>
<ion-option value="2">Ex2</ion-option>
</ion-select>
in your component.ts
onChange($event){
console.log($event.target.value);
}
if you do need two-way data binding, then you have to use ngModel.
Ashley
4 Likes
Thank you. It worked
this is not worked for me. no error it didnt log that event it didnt stop on breakpoint
because ionChange=“onChange($event)” should have (ionChange) need ()
(ionChange)=“onChange($event)”
also
console.log console.log($event.target.value); has error
console.log($event);
it works
15 Likes
Thanks @saber13812002
You saved my time.
3 Likes
thanks you saved my time
thanks saved me sometime this works perfectly