Keep $stateParams between parent states

I’ve got two pages:




They are both activated by IonicTabs. But now I want to keep my $stateParams when switching between these two states. For instance:

From: /partners/save/list/country/2/category/23 to: /partners/save/map/country/2/category/23

How do I do that?

Does it have something to do with $viewState? Can I inject defaults in there or set it to remember it’s previous values?

Last I knew, each ion-tab had its own history stack and should be able to keep it’s location stored when switching between. Are you using the nightly builds?

As always, I’m using the nightly builds. In my case, I don’t want each tab to have it’s own history stack…

So when you navigate away from each tab, you want to destroy the history stack is there, and then when you navigate back you go to the default view for that tab?

Sorry first it seemed like you wanted to save the navigation stack instead of getting rid of it.

I don’t really want anything to do with ‘history’ or ‘navigation stack’.

I just want my $state to keep it’s $stateParams when switching between parent states like in my example.
I don’t need navigation/history logic like back / forward etc.

You might want to dig around in Stack Overflow for this. $state is all the ui-router component - not really specific to Ionic. I’m not sure if this is possible or not.

Have you considered putting this in service? Then, use ui-sref to inject the state params into the links between pages.

Robin, are you calling the states via $state.go() or via url?
I do something similar in one of my controllers, which is shared by a couple of different states/routes. The various views can be accessed via multiple states, each using different $stateParams. The controller just calls the appropriate $state.go() depending on what’s going on. This wouldn’t work if I was changing states via url, though.