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

$state.go not working from inside $stateChangeStart handler #969

Closed
plong0 opened this issue Mar 19, 2014 · 6 comments
Closed

$state.go not working from inside $stateChangeStart handler #969

plong0 opened this issue Mar 19, 2014 · 6 comments

Comments

@plong0
Copy link

@plong0 plong0 commented Mar 19, 2014

I am working on a security module and trying to have the $stateChangeStart event handler redirect $state based on certain conditions.

For example:
I am calling $state.go('login', null, {reload: true, location: 'replace'}) from inside a $stateChangeStart handler with toState 'test'. It seems to start loading the 'login' state, but never finishes loading it, and also finishes loading the 'test' state.

I get a $stateChangeSuccess for 'test', but only a $stateChangeStart for 'login'.

@marcghorayeb
Copy link

@marcghorayeb marcghorayeb commented Mar 19, 2014

Are you calling preventDefault on the first event ?

@nateabele
Copy link
Member

@nateabele nateabele commented Mar 19, 2014

Plunkr?

@plong0
Copy link
Author

@plong0 plong0 commented Mar 19, 2014

event.preventDefault() got it! thanks marcghorayeb!

@plong0 plong0 closed this Mar 19, 2014
@xpepermint
Copy link

@xpepermint xpepermint commented Oct 1, 2014

hum... why is event.preventDefault necessary here?

@nateabele
Copy link
Member

@nateabele nateabele commented Oct 1, 2014

@xpepermint Because he's using the event handler to prevent the initial transition.

@xpepermint
Copy link

@xpepermint xpepermint commented Oct 1, 2014

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.