Transition to the same state
For a game app i have multiple game levels and only one game view. When level 1 is finished level 2 is loaded. So i have to transitionTo the same game view again. The game view then loads the new level data itself.
As workaround i have two states with the same content but different names. Then i transitionTo either one or the other. But i would like to do it in a more elegant way.
To avoid browser history back/next the app has no urls/deeplinking - so url parameters or routes can't be used.
Is there a better way of doing all this?
Just give your state a 'level' parameter. Parameters work even when you
don't have a URL, you just declare them in the 'params' array, e.g.
params: ['level'].
Then just $state.transitionTo('game', { level: 1 }). When you
transition to the same state with different parameters, you get a new
instance of that state.
On Fri, May 31, 2013 at 4:11 AM, bbshopadmin [email protected]:
For a game app i have multiple game levels and only one game view. When level 1 is finished level 2 is loaded. So i have to transitionTo the same game view again. The game view then loads the new level data itself.
As workaround i have two states with the same content but different names. Then i transitionTo either one or the other. But i would like to do it in a more elegant way.
To avoid browser history back/next the app has no urls/deeplinking - so url parameters or routes can't be used.
Is there a better way of doing all this?
— Reply to this email directly or view it on GitHubhttps://github.com/angular-ui/ui-router/issues/156 .
Works great. Sorry, i couldn't find that in the wiki. Thank you!
Yeah, I had the same problem.