An open API service indexing awesome lists of open source software.

https://github.com/normandy72/transition-events

Router State Transition Events in AngularJS. Coursera course "Single Page Web Applications with AngularJS" by Yaakov Chaikin.
https://github.com/normandy72/transition-events

angular angularjs css css3 html html5 javascript js

Last synced: about 1 month ago
JSON representation

Router State Transition Events in AngularJS. Coursera course "Single Page Web Applications with AngularJS" by Yaakov Chaikin.

Awesome Lists containing this project

README

          

# Router State Transition Events
## $stateChangeStart
* Fires when state change transition begins.
* Use `event.preventDefault()` to prevent the transition from occuring.
```
$rootScope.$on('$stateChangeStart',
function(event, toState, toParams, fromState, fromParams, options){
...
}
);
```
## $stateChangeSuccess
* Fired once the state transition is complete.
```
$rootScope.$on('$stateChangeSuccess',
function(event, toState, toParams, fromState, fromParams){
...
}
);
```
## $stateChangeError
* Fires when an error occurs during transition.
```
$rootScope.$on('$stateChangeError',
function(event, toState, toParams, fromState, fromParams, error){
...
}
);
```
***
#### _Summary_
* ui-router exposes numerous state change events that our code is able to listen for.
* All ui-router events are fired on the $rootScope.
* $stateChangeStart - starts the state transition. Call `event.preventDefault()` to prevent the transition.
* $stateChangeSuccess indicates a successful transition end.
* $stateChangeError indicates that the transition failed, including having errors in the resolve. Listen for this event to catch ALL errors during state changes.
***