Ionic Tabs History


#1

Hi there,
I am building an app with the ionic tabs navigation.
Everything works perfectly. However…
When I navigate using the tabs-menu that Ionic created for me, the history doesn’t get cleared. It seems like there is a history stack for every single tab.

Simple example: when I have two tabs: Tab A and Tab B. When I am on Tab A and go on that tab to page 2 inside tab A, everything is fine. But then, when I open Tab B. And go back to Tab A. Page 2 is still active, in stead of page 1 that Tab A is linked to.

I used IonViewDidLeave (and then .backToRoot command) to bypass this, but now I want to reload the first page of each tab when I click on the tab. Anyone have any idea how to do this? So basically clicking on a tab, should open in the same navigationstack or clear the history of the other navigation stacks.

Already found this: Tabs navigation + unique navigation history stack but couldn’t find out how to add this to my current project (latest Ionic version)


#2

Speaking only as a user, what you describe is how I would expect a tabs-based application to behave. Tabs are for presenting “subapplications”, and it makes sense for each of them to have their own state. For example, if I have two tabs: “shop” and “preferences”, and I’m in the middle of searching for products from the “shop” tab, but want to change the shipping address in my preferences, I would be pretty bent if I returned to the “shop” tag and wasn’t restored to exactly where I was before.


#3

I am using ionViewWillEnter() to show new data every time.


#4

Then I don’t think tabs are going to be your friend.


#5

It’s working fine for me.


#6

Then I guess your users don’t share my opinion, because I would consider that not how tabs are supposed to work. If I am doing stuff on tab A, and switch over to tab B to do something else, and go back to tab A, I expect everything to be just as I left it.