# Class TransitionService

This class provides services related to Transitions.

- Most importantly, it allows global Transition Hooks to be registered.
- It allows the default transition error handler to be set.
- It also has a factory function for creating new [[Transition]] objects, (used internally by the [[StateService]]).

At bootstrap, [[UIRouter]] creates a single instance (singleton) of this class.

This API is located at `router.transitionService` ([[UIRouter.transitionService]])

- Defined in router/transition/transition-service.js:63

#####
Index

### Constructors

constructor

### Properties

$get
$view
_criteriaPaths
_deregisterHookFns
_eventTypes
_pluginapi
_registeredHooks
_transitionCount
globals
$inject

### Methods

_defineCoreEvents
_defineCorePaths
_defineEvent
_definePathType
_getEvents
_getPathTypes
_registerCoreTransitionHooks
create
getHooks

##
Constructors

### constructor

- new TransitionService(globals, viewService): TransitionService

- #### Parameters

  - globals: UIRouterGlobals
  - viewService: any

  #### Returns TransitionService

  - Defined in router/transition/transition-service.js:69

##
Properties

### $get

$get: (string | ((stateService: any, urlService: any, stateRegistry: any, viewService: any) => TransitionService))[] = ...

- Defined in router/transition/transition-service.js:93

### $view

$view: any

- Defined in router/transition/transition-service.js:78

### _criteriaPaths

_criteriaPaths: {}

The paths on a criteria object

- Defined in router/transition/transition-service.js:76

### _deregisterHookFns

_deregisterHookFns: {}

- Defined in router/transition/transition-service.js:79

### _eventTypes

_eventTypes: any[]

The transition hook types, such as `onEnter`, `onStart`, etc

- Defined in router/transition/transition-service.js:72

### _pluginapi

_pluginapi: any

- Defined in router/transition/transition-service.js:80

### `Internal`_registeredHooks

_registeredHooks: {}

The registered transition hooks

- Defined in router/transition/transition-service.js:74

### _transitionCount

_transitionCount: number

- Defined in router/transition/transition-service.js:70

### globals

globals: UIRouterGlobals

- Defined in router/transition/transition-service.js:77

### `Static`$inject

$inject: string[] = ...

- Defined in router/transition/transition-service.js:64

##
Methods

### _defineCoreEvents

- _defineCoreEvents(): void

- #### Returns void

  - Defined in router/transition/transition-service.js:166

### _defineCorePaths

- _defineCorePaths(): void

- #### Returns void

  - Defined in router/transition/transition-service.js:211

### _defineEvent

- _defineEvent(name, hookPhase, hookOrder, criteriaMatchPath, reverseSort?, getResultHandler?, getErrorHandler?, synchronous?): void

- #### Parameters

  - name: any
  - hookPhase: any
  - hookOrder: any
  - criteriaMatchPath: any
  - reverseSort: boolean = false
  - getResultHandler: ((hook: any) => ((result: any) => any)) = TransitionHook.HANDLE_RESULT
    - - (hook): ((result: any) => any)

      - These GetResultHandler(s) are used by [[invokeHook]] below Each HookType chooses a GetResultHandler (See: [[TransitionService._defineCoreEvents]])

        #### Parameters

        - hook: any

        #### Returns ((result: any) => any)

        - - (result): any

          - #### Parameters

            - result: any

            #### Returns any

  - getErrorHandler: (() => ((error: any) => any)) = TransitionHook.REJECT_ERROR
    - - (): ((error: any) => any)

      - #### Returns ((error: any) => any)

        - - (error): any

          - #### Parameters

            - error: any

            #### Returns any

  - synchronous: boolean = false

  #### Returns void

  - Defined in router/transition/transition-service.js:220

### _definePathType

- _definePathType(name, hookScope): void
- `Internal`

  Adds a Path to be used as a criterion against a TreeChanges path

  For example: the `exiting` path in [[HookMatchCriteria]] is a STATE scoped path. It was defined by calling `defineTreeChangesCriterion('exiting', TransitionHookScope.STATE)` Each state in the exiting path is checked against the criteria and returned as part of the match.

  Another example: the `to` path in [[HookMatchCriteria]] is a TRANSITION scoped path. It was defined by calling `defineTreeChangesCriterion('to', TransitionHookScope.TRANSITION)` Only the tail of the `to` path is checked against the criteria and returned as part of the match.

  #### Parameters

  - name: any
  - hookScope: any

  #### Returns void

  - Defined in router/transition/transition-service.js:266

### _getEvents

- _getEvents(phase): any[]

- #### Parameters

  - phase: any

  #### Returns any[]

  - Defined in router/transition/transition-service.js:244

### _getPathTypes

- _getPathTypes(): {}

- #### Returns {}

  - Defined in router/transition/transition-service.js:270

### _registerCoreTransitionHooks

- _registerCoreTransitionHooks(): void

- #### Returns void

  - Defined in router/transition/transition-service.js:278

### create

- create(fromPath, targetState): Transition
- `Internal`

  Creates a new [[Transition]] object

  This is a factory function for creating new Transition objects. It is used internally by the [[StateService]] and should generally not be called by application code.

  #### Parameters

  - fromPath: any

    the path to the current state (the from state)

  - targetState: any

    the target state (destination)

  #### Returns Transition

  a Transition

  - Defined in router/transition/transition-service.js:162

### getHooks

- getHooks(hookName): any

- #### Parameters

  - hookName: any

  #### Returns any

  - Defined in router/transition/transition-service.js:274