preselect ionic picker selected value code example
Example: preselect ionic picker selected value
async openResultsShownPicker() {
const columns = [{name:"resultsShown",options:this.resultsShownOptions, selectedIndex: this.filters.resultsShownIdx }];
const translations = await this.translateService.get(['COMMON.CANCEL','COMMON.DONE']).toPromise()
let picker = await this.pickerController.create({
buttons: [
{
text: translations['COMMON.CANCEL'],
role: 'cancel',
handler:value => {
picker.dismiss(value,'cancel');
return false;
}
},
{
text: translations['COMMON.DONE'],
role: 'done',
handler:value => {
picker.dismiss(value,'done');
}
}
],
columns: columns
});
picker.present();
picker.onDidDismiss().then(async data => {
let col = await picker.getColumn('resultsShown');
console.log("data",data);
if (data.role == 'done') {
this.updateResults(col);
}
});
}