constructor(nav: NavController) {
this.nav = nav;
}
presentActionSheet() {
let actionSheet = ActionSheet.create({
title: 'Leave this page',
buttons: [
{
text: 'Destructive',
style: 'destructive',
handler: () => {
this.nav.pop() //pop not work here!
}
},
{
text: 'Cancel',
style: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
}
]
});
this.nav.present(actionSheet);
}
Try:
this.nav.remove().then(() => {
this.nav.pop();
});
ActionSheets and Alerts get added to the navigation stack, so the remove will remove it from the stack, then the pop will take the user back a page.
1 Like
1 Like
I had the same issue and solved by using this code:
handler: () => { this.nav.pop().then(()=>{this.nav.pop()}) }
2 Likes
This worked for me. In my case, I simply imported AlertController and the NavController.pop() doesn’t work, and I had to use your trick. Didn’t even put NavController.pop() inside the alert, just a normal method call on (click) in a button.