Reputation: 2178
I have an ActionSheet in Ionic 3 and the last button of that is for Displaying more option. When the button is clicked 2 more buttons should be added on the ActionSheet. The problem is when I clicked any button, the ActionSheet is getting closed. I could not find out a way to stop it from closing. Is there any way to stop ActionSheet from closing?
onMore(){
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Option 1',
handler: () => {
}
},
{
text: 'More',
handler: () => {
this.showMore(actionSheet);
}
}
]
});
actionSheet.present();
}
private showMore(actionSheet){
actionSheet.addButton({
text: 'Option 2',
handler: () => {
}
});
}
Upvotes: 3
Views: 449
Reputation: 5265
It is simple.
Just add return false
to your handler like below.
onMore(){
let actionSheet = this.actionSheetCtrl.create({
buttons: [
{
text: 'Option 1',
handler: () => {
}
},
{
text: 'More',
handler: () => {
this.showMore(actionSheet);
return false;
}
}
]
});
actionSheet.present();
}
Upvotes: 4