Navigate back multiple pages


#1

Is there a way to navigate back multiple pages in ionic3 like $ionicHistory.back(numberOfPages) in ionic v1?


#2

Any help? pop() only go back one page. push() does not clear navigation stack. What should I do?


#3

You can use remove() to remove pages, then pop back to the last page that wasn’t removed.


#4

I made a plunker http://plnkr.co/edit/5ciTDxxBOF50F737kKS5?p=preview.
It seems that remove only works if remove count is 1. Is this a bug?


#5

I don’t understand your code. Say you want to go back 5 pages. How about:

  1. Get index of current view in the current navcontroller.
  2. Subtract 5.
  3. From that point in the nav stack, remove 3 pages.
  4. Pop from your current view to the target page.

Are you saying there’s a bug in that strategy?


#6

I misunderstood the parameter of remove method. I have updated the plunker to fix that.


#7

I had Face the same issue from navigate back between multiple pages so my hierarchy is
homepage->2 page->3 page->4 page, i would like to go back from 4th page to second page i had write

 navCtrl.popTo( this.navCtrl.getByIndex(1))

and it works for me.