The signature for Angular 1 State Transition Hooks.
The signature for Angular 1 State Transition Hooks.
State hooks are registered as onEnter/onRetain/onExit in state declarations. State hooks can additionally be injected with $transition$ and $state$ for the current Transition and StateObject in the transition.
Transition State Hooks are callback functions that hook into the lifecycle events of specific states during a transition. As a transition runs, it may exit some states, retain (keep) states, and enter states. As each lifecycle event occurs, the hooks which are registered for the event and that state are called (in priority order).
onEnter: function() { console.log('Entering'); }
Not minification-safe
onRetain: function($state$) { console.log('Retained ' + $state$.name); }
Annotated for minification-safety
onExit: [ '$transition$', '$state', function($transition$, $state) {
// always redirect to 'foo' state when being exited
if ($transition$.to().name !== 'foo') {
return $state.target('foo');
}
} ]
an optional HookResult which may alter the transition
Generated using TypeDoc
The signature for Angular 1 State Transition Hooks.
State hooks are registered as onEnter/onRetain/onExit in state declarations. State hooks can additionally be injected with $transition$ and $state$ for the current Transition and StateObject in the transition.
Transition State Hooks are callback functions that hook into the lifecycle events of specific states during a transition. As a transition runs, it may exit some states, retain (keep) states, and enter states. As each lifecycle event occurs, the hooks which are registered for the event and that state are called (in priority order).
See also:
Example:
onEnter: function() { console.log('Entering'); }
Not minification-safe
onRetain: function($state$) { console.log('Retained ' + $state$.name); }
Annotated for minification-safety
onExit: [ '$transition$', '$state', function($transition$, $state) { // always redirect to 'foo' state when being exited if ($transition$.to().name !== 'foo') { return $state.target('foo'); } } ]