-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Unable to access event.currentScope in $stateChangeSuccess #1005
Comments
I did some debugging into the $broadcast method and I think I understood the problem: Chrome Dev Tools (and Firefox too) displays directly the Scope object in the second log ( But with the first log ( I think crazy things can happened when using a $timeout function referencing the event.currentScope for the same reason so it's a real bug. But it concerns AngularJS, not the UI-Router. I'll make a PR. |
To be clear, there is no explicit support or notion of a 'current scope' when it comes to state events. There are a number of reasons for this, including the fact that a state can be attached to to any number of scopes from zero to infinity (because a state can have any number of views). Secondly, it crosses the abstraction boundary between view management and the state machine. |
Thanks for explanation @nateabele. Here is the end of the story: I submit a PR about this problem. A correction arises from this, consisting in setting |
I searched a way to get the scope associated to the current state. I used the $stateChangeSuccess event who expose the event.currentScope... but I found a strange behavior when logging the event.currentScope :
The first console.log displays the whole event object, and I can see what I need under the property currentScope.
But if I try to log specifically
event.currentScope
, I get an another scope (the $rootScope, I think).With console.log or anything else, I can't get the currentScope.
See it in action here : http://jsfiddle.net/Cuicui74/HxrSd/11/ (open console).
The text was updated successfully, but these errors were encountered: