Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change URL (without state change) in onExit #3194

Closed
felixruponen opened this issue Dec 9, 2016 · 3 comments
Closed

Change URL (without state change) in onExit #3194

felixruponen opened this issue Dec 9, 2016 · 3 comments

Comments

@felixruponen
Copy link

My use case is as follows. I need to alter the url just before the current state has exited.

I have tried using the regular $state.go without luck (it will just give me an exception saying "The transition has been superseded by a different transition")

Is it possible to perform a state change in a transition hook?

PS. I'm using ui-router 1.0

@felixruponen
Copy link
Author

So I've, done some searching and found #2977 were someone suggests using $state.target for simply redirecting to another state. But this won't work for me since I need to first update the current state and then continue with the original transition.

@felixruponen
Copy link
Author

Ok, so this can be "fixed" by returning false in the onExit and starting a new $state.go inside a $timeout allowing the original transition to finish. Not sure if there is a better way to do this though.

@christopherthielen
Copy link
Contributor

Can you create a state that has the temporary url?

If so, you can redirect to that in onExit. Pass the current transitions' , then tell that state where to go in the end.

http://plnkr.co/edit/o3q5bc7sX4oWADKupIBA?p=preview

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants