Nav.pop not work with ActionSheet and Alert


#1
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);
}

#2

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.


#3

#4

I had the same issue and solved by using this code:

handler: () => { this.nav.pop().then(()=>{this.nav.pop()}) }


#5

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.