I’m really struggling with tab navigation.
As I understand it, each tab has it’s own navigation stack and when I request an instance of the navController it will automatically get the nearest navigation controller, right?
So I have a basic 3-tab application. From tab 2, I want to clear the navigation stack of that one then I want to move to a different tab and push a page onto that stack. However, from the documentation I’m struggling to figure out how to do this.
At the moment, I’m using this.navCtrl.popToRoot() to clear the navigation stack of the current tab. That kinda appears to work. Next, I’m using this.navCtrl.parent.select(TabsPage.AccountTab) to navigate over to the AccountTab, but I don’t want to go to the root of that tab, I want to navigate to a different page on that navigation stack. How do I achieve that?
Is it possible to retrieve an instance of the AccountTab controller, push a page onto it’s stack and THEN move the user to that page? At the moment, I can only switch over to the root of the Account tab.
Thank you for reading and much love to anyone willing to gimme a hand!
UPDATE: One thing I tried without success is publishing an event when I’m in Tab 2 and then subscribing to the event from the root page of Tab 3, but the event doesn’t get executed for some reason!
UPDATE 2:
On another thread, someone suggested this code, which seemed to work for me:
setTimeout(() => {this.navCtrl.parent.getSelected().push(OrderStatusPage)}, 100);
I have no idea how that makes it work for me though, and it seems a bit dodgy!
Surely, there’s a better way?