Skip to content

Added stateChangeComplete event #1113

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
* @eventOf ui.router.state.$state
* @eventType broadcast on root scope
* @description
* Fired once the state transition is **complete**.
* Fired once the state transition is **success**.
*
* @param {Object} event Event object.
* @param {State} toState The state being transitioned to.
Expand All @@ -925,6 +925,22 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
* @param {Object} fromParams The params supplied to the `fromState`.
*/
$rootScope.$broadcast('$stateChangeSuccess', to.self, toParams, from.self, fromParams);

/**
* @ngdoc event
* @name ui.router.state.$state#stateChangeComplete
* @eventOf ui.router.state.$state
* @eventType broadcast on root scope
* @description
* Fired once the state transition is **complete**.
*
* @param {Object} event Event object.
* @param {State} toState The state being transitioned to.
* @param {Object} toParams The params supplied to the `toState`.
* @param {State} fromState The current state, pre-transition.
* @param {Object} fromParams The params supplied to the `fromState`.
*/
$rootScope.$broadcast('stateChangeComplete', to.self, toParams, from.self, fromParams);
}
$urlRouter.update(true);

Expand Down Expand Up @@ -953,6 +969,22 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
*/
evt = $rootScope.$broadcast('$stateChangeError', to.self, toParams, from.self, fromParams, error);

/**
* @ngdoc event
* @name ui.router.state.$state#stateChangeComplete
* @eventOf ui.router.state.$state
* @eventType broadcast on root scope
* @description
* Fired once the state transition is **complete**.
*
* @param {Object} event Event object.
* @param {State} toState The state being transitioned to.
* @param {Object} toParams The params supplied to the `toState`.
* @param {State} fromState The current state, pre-transition.
* @param {Object} fromParams The params supplied to the `fromState`.
*/
$rootScope.$broadcast('stateChangeComplete', to.self, toParams, from.self, fromParams);

if (!evt.defaultPrevented) {
$urlRouter.update();
}
Expand Down