Pop TabsPage and push LoginPage?

I know I am late to the party, and this is a few months old already.

But I think the code you are looking for is to access the root nav from the App utility class (https://ionicframework.com/docs/api/components/app/App/) using getRootNav() and pop() from there.

Ionic Tabs have a strange navigation stack (it’s not so strange when you think why). The <ion-tabs> instance is pushed to the root nav, and each <ion-tab> has its own NavController. This is so you can push as deep as you need to per tab, and simply switch to another tab without screwing up the other tab’s navigation stack.

Essentially what you want to do is this on one of your pages:

logout() {
  this.app.getRootNav().pop();
}

The <ion-tabs> is pushed to the root navigation stack, and each tab’s individual navigation stack is a child to this, so is not part of the root. Make sense?

2 Likes