How can I prevent user from navigating back to a specific page?

I got an intermediate page that I want to prevent user from being able to navigate back to, neither from the header bar nor from Android’s back button.

What I have tried is to put the following code into the page that the IntermediatePage leads to:

  ngAfterViewInit() {
    const prevView = this.nav.getPrevious(this.viewController);

    if (prevView && prevView.instance.name === 'IntermediatePage') {
      this.nav.remove(prevView.index);
    }
  }

but it doesn’t seem to work. Is there a better approach that can actually work?

I am just browsing really quickly on my phone, but I think you are using 1 = too many…

Instead of 3 === use 2 ==

was just browsing through the @beta12 milestones on github and i think this is your issue…

it’s one of 3 left so hopefully this will be solved in @beta12

Current document does state remove() http://ionicframework.com/docs/v2/api/components/nav/NavController/

did you change that? to:

if (prevView && prevView.instance.name == 'IntermediatePage')