Go to root page from a tab

一曲冷凌霜 提交于 2019-12-03 08:06:22

Just like you can see in the docs

Notice that each <ion-tab> binds to a [root] property, just like in the Navigation section above. That is because each <ion-tab> is really just a navigation controller. This means that each tab has its own history stack, and NavController instances injected into children @Components of each tab will be unique to each tab

So when setting a page as root, you're using the navigation stack from that tab, and not the one of the entire app. That's why you need to get the main navigation stack by doing:

constructor(private app: App,...) {...}

And then

yourMethod(): void {
    this.app.getRootNav().setRoot(YourPage);
}

just try this it work great for me

this.childNavCtrl.setRoot(HomePage);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!