-
Notifications
You must be signed in to change notification settings - Fork 9
Transition provider stage handlers
Jens Melgaard edited this page Jul 29, 2013
·
4 revisions
Stage handlers refer to handlers that target specific stages a transition can have.
Basically this boils down to before
, between
, after
. The flow of these will be:
- Handler: Before
- Event:
$stateChangeStart
- Resolve: Views, Dependencies etc.
- Handler: Between
- Event:
$stateChangeSuccess
or$stateChangeError
- Handler: After
When registering a transition handler as a function, it will be the between handler we target. Like in the example below:
angular.module('door', ['dotjem.routing']).
config(['$stateTransitionProvider', function($stateTransitionProvider) {
$stateTransitionProvider
.transition('*', '*', function($transition) {
console.log('This is the Between handler saying Hello!');
})
}]);
If we wish to target before, after we need to provide an object as a handler defining which ones to target:
angular.module('door', ['dotjem.routing']).
config(['$stateTransitionProvider', function($stateTransitionProvider) {
$stateTransitionProvider
.transition('*', '*', {
before: function($transition) {
console.log('This is the Before handler saying Hello!');
},
between: function($transition) {
console.log('This is the Between handler saying Hello!');
},
after: function($transition) {
console.log('This is the After handler saying Hello!');
}
)
}]);
We don't have to define all of them, we could settle for just one or two of them.
angular.module('door', ['dotjem.routing']).
config(['$stateTransitionProvider', function($stateTransitionProvider) {
$stateTransitionProvider
.transition('*', '*', {
after: function($transition) {
console.log('This is the After handler saying Hello!');
}
)
}]);
- Route Provider
- Basic Configuration
- Parameters and Converters
- Decorators
- Case Sensitivity
- A Word on Trailing Slashes
- Legacy Support
- State Provider
- Basic Configuration
- Hierarchy Configuration
- Views
- Routes
- Transitions
- Resolve
- State Service
- Transition Provider
- Basic Configuration
- Stage Handlers
- Targeting Multiple States
- View Provider
- Updating Views
- Transactions
- Scroll Provider