I'm working on ionic2 project. I use ion-select element.
I search after a way to close the select-box programmatically on select any item (not wait the user to press OK).
<ion-select id="select" #select>
<ion-option (ionSelect)="closeAndSave()" *ngFor="let option of enumList" [value]="option">{{ option}}</ion-option>
</ion-select>
`
class myClass{
@viewChild('select') select:Select;
closeAndSave(){
/*it is come here on press any option. but how can I close here my select element? I tried: this.select.destroy() - not do any thing. any solution?*/
}
`
this is what I did:
this.court = val;
this.select.close();
put this inside your closeAndSave
function.
Before that u need to pass some value from your closeAndSave function like:
(ionSelect)="closeAndSave('someValueHere')"
then use this value there in you TS code:
import { Select } from 'ionic-angular';
class myClass{
@ViewChild(select) select:Select;
closeAndSave(val){
this.someVar = val;
this.select.close();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With