Returns all the registered hooks of a given hookName
type
Returns all the registered hooks of a given hookName
type
Registers a callback function as an onBefore
Transition Hook.
Registers a callback function as an onBefore
Transition Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
onBefore
hooks are injected and invoked before a Transition starts. No resolves have been fetched yet.
Each onBefore
hook is invoked synchronously, in priority order, and are typically invoked in the same call
stack as StateService.transitionTo.
During the onBefore
phase, the Transition additional hooks can be registered "on-the-fly" using, for example,
$transition$.onStart()
or $transition$.onFinish()
.
The current Transition can be injected as $transition$
.
The hook's return value can be used to modify the current Transition:
false
: this will abort the current transitionfalse
or a TargetStateIf any hook modifies the transition synchronously (by returning false
or a TargetState), the remainder
of the hooks do not get invoked. If any hook returns a promise, the remainder of the onBefore
hooks are still
invoked. Any promises are then handled asynchronously, during the onStart
phase of the Transition.
This example redirects any transition from 'home' to 'home.dashboard'. This is commonly referred to as a "default substate".
defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onEnter
Transition+State Hook.
Registers a callback function as an onEnter
Transition+State Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
Note: for onEnter
hooks, the to
in the matchCriteria
matches the entering state, not the Transition "to state".
onEnter
hooks are invoked asynchronously, in priority order, when the Transition is entering a state. States
are entered after the onRetain
hooks.
Note: a high priority onEnter
hook fetches any Lazy Resolves defined for the state being entered.
The current Transition can be injected as $transition$
.
Any resolves which the entering state has access to may be injected.
The hook's return value can be used to modify the current Transition:
false
: this will abort the current transitionfalse
or a TargetStateState hooks can be registered using $transitions
(TransitionService), as an onBefore
"on-the-fly" registration
using $transition$
(the Transition instance), or as part of a state declaration.
This example uses a service to log that a user has entered the admin section of an app. This assumes that there are substates of the "admin" state, such as "admin.users", "admin.pages", etc.
defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onError
Transition Hook.
Registers a callback function as an onError
Transition Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
onError
hooks are chained off the Transition's promise. If the Transition fails, the promise
is rejected, and the onError
hooks are then invoked.
The failed Transition can be injected as $transition$
.
The transition rejection reason can be injected as $error$
Since the Transition is already completed, the hook's return value is ignored
defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onExit
Transition+State Hook.
Registers a callback function as an onExit
Transition+State Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
Note: for onExit
hooks, the from
in the matchCriteria
matches the exiting state, not the Transition "from state".
onExit
hooks are invoked asynchronously, in priority order, when the Transition is exiting a state. States
are exited after the Transition's onStart
phase is complete.
The current Transition can be injected as $transition$
.
Any resolves which the exiting state has access to may be injected.
The hook's return value can be used to modify the current Transition:
false
: this will abort the current transitionfalse
or a TargetStateState hooks can be registered using $transitions
(TransitionService), as an onBefore
"on-the-fly" registration
using $transition$
(the Transition instance), or as part of a state declaration.
defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onFinish
Transition Hook.
Registers a callback function as an onFinish
Transition Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
onFinish
hooks are invoked asynchronously, in priority order, just before the Transition completes, after
all states are entered and exited.
The current Transition can be injected as $transition$
.
Any resolves which the "to state" has access to may be injected.
The hook's return value can be used to modify the current Transition:
false
: this will abort the current transitionfalse
or a TargetStatedefines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onRetain
Transition+State Hook.
Registers a callback function as an onRetain
Transition+State Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
Note: for onRetain
hooks, the to
in the matchCriteria
matches the retained state, not the Transition "to state".
onRetain
hooks are invoked asynchronously, in priority order, after onExit
hooks.
The current Transition can be injected as $transition$
.
Any resolves which the retained state has access to may be injected.
The hook's return value can be used to modify the current Transition:
false
: this will abort the current transitionfalse
or a TargetStateState hooks can be registered using $transitions
(TransitionService), as an onBefore
"on-the-fly" registration
using $transition$
(the Transition instance), or as part of a state declaration.
defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onStart
Transition Hook.
Registers a callback function as an onStart
Transition Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
onStart
hooks are invoked asynchronously, in priority order, when the Transition starts running.
At this point, the Transition has not exited nor entered any states yet.
Note: a high priority onStart
hook will fetch any Eager Resolves in the "to path", which were not already fetched.
The current Transition can be injected as $transition$
.
Any resolves which the target state has access to may be injected.
The hook's return value can be used to modify the current Transition:
false
: this will abort the current transitionfalse
or a TargetStateThis example intercepts any transition to a state which requires authentication, when the user is not currently authenticated. It allows the user to authenticate asynchronously, then resumes the transition. If the user did not authenticate successfully, it redirects to the "guest" state, which does not require authentication.
This example assumes:
'auth'
state.MyAuthService.isAuthenticated()
synchronously returns a boolean.MyAuthService.authenticate()
presents a login dialog, and returns a promise which is resolved
or rejected, whether or not the login attempt was successful.defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Registers a callback function as an onSuccess
Transition Hook.
Registers a callback function as an onSuccess
Transition Hook.
The matchCriteria
is used to determine which Transitions the hook should be invoked during.
onSuccess
hooks are chained off the Transition's promise. If the Transition is successful, the promise
is resolved, and the onSuccess
hooks are then invoked.
The successful Transition can be injected as $transition$
.
Any previously fetched resolves which the "to state" has access to may be injected. These hooks will not trigger/wait for any unfetched resolves to fetch.
Since the Transition is already completed, the hook's return value is ignored
defines which Transitions the Hook should be invoked for.
the hook function which will be injected and invoked.
a function which deregisters the hook.
Generated using TypeDoc
This interface specifies the api for registering Transition Hooks. Both the TransitionService and also the Transition object itself implement this interface. Note: the Transition object only allows hooks to be registered before the Transition is started.