I am working with Ionic4, trying to get tabs set up.
I wanted to have individual navigation stacks in each tab…
The tab bar persists at the bottom of most pages, and within each tab, I can navigate through various pages.
In Ionic 3…
When I switch tabs, I go back to the last page I visited on that tab, and can push / pop on that particular navigation stack.
In Ionic 4…
When I switch tabs, I go back to the root page.
I have tried with a “routed” setup where I change the route to go to new pages, and with an ion-nav then push/pop components to the stack.
Neither option has worked.
I think this is a fundamental aspect of the tabs feature, but I’m really struggling to get anything working.
import { Nav } from '@ionic/angular';
import { Page2Component } from './page2.component.ts';
...
constructor(
public navCtrl: Nav
) { }
...
gotoPage2(){
this.navCtrl.push(Page2Component);
}
The tabs now seem to have their own nav stacks.
Not ideal as it is not using the angular router / ion-router-outlet.
Hi in the latest ionic 4 this isn’t working.
ion-tab not exists.
If I modify your code with the new tabs structure, and then place the ion-nav inside the ion-tab-buttons, than the pages rendered inside the tab buttons. So that’s not good.
Do you have any other solution? Since this post is quite old, maybe there is better solution.
We migrating ionic 3 app to ionic 4, and created the tabs with angular router.
But we have shared pages what we need to push and pop to the nav stack. We tried to use separate route for those shared components, but this part of the application is to complex to refactor. We want to stick to the push and pop style within tabs, is that even possible?
Thanks.
In my case, finally in the <ion-tab-button> for Ionic 5, I had to combine tab with routerLink and it works perfectly for me: The reason? I don’t know hehe! But I found no other way without using the eventHandler, navController and without handling lifecycle: