EXIT ion-tabs

Hi !

I try to exit my ion-tabs when I logout but I can’t. I tried let nav = this.app.getRootNav();
nav.push(AccueilPage); but that doesn’t work. Have you an idea please ?

Use setRoot instead of push

Many examples in this forum

Yes ! I read many articles i work since 3 hours for this problem :’( I tried setRoot and many other things but that doesn’t work :frowning:

With setRoot that’s work only the first time…

So basicly you just want to hide the tabs am I right ?

1 Like

Yes ! I have a tabs where I have a logout button So I just want to remove the token and go on my first page without tabs. I found many issues in the forum but no solution for my app…

To simply hide your tabs use this code

    let tabs = document.querySelectorAll('.show-tabbar');
    if (tabs !== null) {
      Object.keys(tabs).map((key) => {
        tabs[key].style.display = 'none';

To show it again change none to flex.

1 Like

Thank for the solution but is it a salution with setRoot or push because with your solution, my stack keep tabs ?

As far as I know, if you start initilizing your application with Tabs it will stay there and the only possible thing todo is to simply set it to an empty state -> ‘none’.

If someone knows how to completly unload them I would be very interested to hear it.

But I don’t start with tabs page but with my ConnexionPage So it’s weird but thanks.

Then how do you even start displaying tabs if you don’t start with Tabspage ?

First, I have my Log Page and When I’m connected, I do setRoot(TabsPage) and the problem is when I logout to go again on Log Page…

I might found what you need!

Use this command removeView(viewController)

As example:

This will remove the Tabbar from the navStack like you wanted!

1 Like

Plse share more code

Html/ts of the root tab definition and the ts which handles the logout

Imho the solution still is a setRoot

This does it for me


Thanks but how Can I access to Tabbar please ?

Also how you set it as rootpage.

thanks that work ! But I have just one question, what is the difference between this.app.getRootNav().setRoot() and this.navCtrl.setRoot() ?

Thanks again !

Hi, you r welcome

The navigation context: top root of the app or the embedded tab view (this.navctrl assumingly refers to)

Plse mark solution as solution, if u like it!


1 Like

And in practical, what’s the difference ?