-
Notifications
You must be signed in to change notification settings - Fork 9
State provider transitions
Transitions are more thoroughly covered under the Transition Provider section.
But since the $stateProvider
provides a number of sort hands for certain transitions, those will be covered here.
On enter transitions can be defined directly on a state like so:
angular.module('phonecat', ['dotjem.routing']).
config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('phones', { onEnter: function($transition) { } })
.state('tablets', {
onEnter: {
from: 'phones', handler: function($transition) { }
}
})
.state('convertible', {
onEnter: {
from: '*', handler: {
before: function($transition) { },
between: function($transition) { },
after: function($transition) { }
}
}
})
}]);
All these are just special case transitions and can be defined like below as well:
angular.module('phonecat', ['dotjem.routing']).
config(['$stateTransitionProvider', function($stateTransitionProvider) {
$stateTransitionProvider
.transition('*', 'phones', function($transition) { })
.transition('phones', 'tablets', function($transition) { })
.transition('*', 'convertible' {
before: function($transition) { },
between: function($transition) { },
after: function($transition) { }
});
}]);
Note: The above doesn't use the Angular array notation for dependencies, this is to make the examples easier to read, you should use the array notation in production, or it won't work if minified.
Very similar to On Enter, On Exit can be defined directly on a state.
angular.module('phonecat', ['dotjem.routing']).
config(['$stateProvider', function($stateProvider) {
$stateProvider
.state('phones', { onExit: function($transition) { } })
.state('tablets', {
onExit: {
to: 'phones', handler: function($transition) { }
}
})
.state('convertible', {
onExit: {
to: '*', handler: {
before: function($transition) { },
between: function($transition) { },
after: function($transition) { }
}
}
})
}]);
And again, just as with on enter, these are just special case transitions and can be defined like below as well:
angular.module('phonecat', ['dotjem.routing']).
config(['$stateTransitionProvider', function($stateTransitionProvider) {
$stateTransitionProvider
.transition('phones', '*', function($transition) { })
.transition('tablets', 'phones', function($transition) { })
.transition('convertible', '*' {
before: function($transition) { },
between: function($transition) { },
after: function($transition) { }
});
}]);
Note: The above doesn't use the Angular array notation for dependencies, this is to make the examples easier to read, you should use the array notation in production, or it won't work if minified.
- 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