March 24, 2014, 6:10pm
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:
How do I do that?
March 24, 2014, 6:16pm
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?
March 24, 2014, 7:17pm
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.
March 24, 2014, 7:43pm
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.