Close push nav when change tab


I have 2 tabs.

First, from tab 1, I open a page with NavController and push.
Then I go to tab 2 and, on returning to tab 1, the page on which I clicked is still open. I want when I change Tab to close those pages, can anyone help me?

Thank you

You can try navCtrl.pop() to remove the page from navigation stack.

I think this breaks the UX contract of tabs. Tabs are meant to be little "sub-app"s that are independent of one another, so actions taken inside one of them should not alter the navigation state of another.

1 Like

I’m sorry but I’ve never used this. Could you give me an example?

I understand but, can’t u close the sub-page when change tab?

Using is a good idea. Or you can do this in your tabs template using tabsHideOnSubPages attribute.

  <ion-tab [root]="tab2Root" tabTitle="About" tabIcon="information-circle" tabsHideOnSubPages="true"></ion-tab>
  <ion-tab [root]="tab3Root" tabTitle="Contact" tabIcon="contacts"></ion-tab>

I’m not talking can/can’t. I’m talking should/shouldn’t.

Hi @NurGuz used in where ?