[SOLVED] How to implement ion-tabs properly when logging out/in again?


#1

SOLVED. You have to get the rootNav because tab has its own navCtrl.

this.app.getRootNav().popToRoot().then(() => {
this.app.getRootNav().setRoot(LoginPage);
});

I noticed that whenever I logout and log back in, there are some views that are repeatedly called.

My app configuration is as following:

rootPage = TabsPage
TabsPage (default index) -> HomePage
HomePage (logout) -> LoginPage
HomePage (if not authenticated) -> LoginPage

When logging in, I use navCtrl.setRoot(TabsPage);
When logging out, I use navCtrl.setRoot(LoginPage);

I did some reading on Nav Hierarchy here: https://webcake.co/exploring-nav-hierarchy-in-the-ionic-2-tabs-page/
and tried implementing the solutions as stated there, but to no avail.

Can anyone point me in the right direction? Thanks.

And after logging out again for the 2nd time, I encounter the following error.