The master class used to instantiate an instance of UI-Router.

UI-Router (for each specific framework) will create an instance of this class during bootstrap. This class instantiates and wires the UI-Router services together.

After a new instance of the UIRouter class is created, it should be configured for your app. For instance, app states should be registered with the UIRouter.stateRegistry.

Normally the framework code will bootstrap UI-Router. If you are bootstrapping UIRouter manually, tell it to monitor the URL by calling UrlService.listen then UrlService.sync.

### Hierarchy

- UIRouter

## Index

### Constructors

- constructor

### Properties

- globals
- locationConfig
- locationService
- stateRegistry
- stateService
- trace
- transitionService
- urlMatcherFactory
- urlRouter
- urlService
- viewService

### Methods

- disposable
- dispose
- getPlugin
- plugin

## Constructors

- new UIRouter(locationService?: LocationServices, locationConfig?: LocationConfig): UIRouter

- Creates a new `UIRouter` object

- Creates a new `UIRouter` object

  #### Parameters

  - ##### locationService: Default value LocationServices = UrlService.locationServiceStub

    :

    a LocationServices implementation

  - ##### locationConfig: Default value LocationConfig = UrlService.locationConfigStub

    :

    a LocationConfig implementation

  #### Returns UIRouter

  - Defined in router.ts:107

## Properties

globals: UIRouterGlobals = new UIRouterGlobals()

Global router state

Global router state

- Defined in router.ts:49

locationConfig: LocationConfig

a LocationConfig implementation

a LocationConfig implementation

- Defined in router.ts:118

locationService: LocationServices

a LocationServices implementation

a LocationServices implementation

- Defined in router.ts:117

stateRegistry: StateRegistry = new StateRegistry(this)

Provides a registry for states, and related registration services

Provides a registry for states, and related registration services

- Defined in router.ts:67

stateService: StateService = new StateService(this)

Provides services related to states

Provides services related to states

- Defined in router.ts:70

trace: Trace = trace

Provides trace information to the console

Provides trace information to the console

- Defined in router.ts:43

transitionService: TransitionService = new TransitionService(this)

Provides services related to Transitions

Provides services related to Transitions

- Defined in router.ts:52

urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory()

Deprecated for public use. Use urlService instead.

Deprecated for public use. Use urlService instead.

deprecated

  Use urlService instead

- Defined in router.ts:58

urlRouter: UrlRouter = new UrlRouter(this)

Deprecated for public use. Use urlService instead.

Deprecated for public use. Use urlService instead.

deprecated

  Use urlService instead

- Defined in router.ts:64

urlService: UrlService = new UrlService(this)

Provides services related to the URL

Provides services related to the URL

- Defined in router.ts:73

viewService: ViewService = new ViewService()

Provides services related to ui-view synchronization

Provides services related to ui-view synchronization

- Defined in router.ts:46

## Methods

- disposable(disposable: Disposable): void

- Registers an object to be notified when the router is disposed

- Registers an object to be notified when the router is disposed

  #### Parameters

  - ##### disposable Disposable

  #### Returns void

  - Defined in router.ts:80

- dispose(disposable?: any): void

- Disposes this router instance

- Disposes this router instance

  When called, clears resources retained by the router by calling `dispose(this)` on all registered disposable objects.

  Or, if a `disposable` object is provided, calls `dispose(this)` on that object only.

  #### Parameters

  - ##### disposable: Optional any

    :

    (optional) the disposable to dispose

  #### Returns void

  - Defined in router.ts:94

- getPlugin(pluginName: string): UIRouterPlugin

- Returns registered plugins

- getPlugin(): UIRouterPlugin[]

- Returns registered plugins

  Returns the registered plugin of the given `pluginName`. If no `pluginName` is given, returns all registered plugins

  #### Parameters

  - ##### pluginName string

    :

    (optional) the name of the plugin to get

  #### Returns UIRouterPlugin

  :

  the named plugin (undefined if not found), or all plugins (if `pluginName` is omitted)

  - Defined in router.ts:209

- #### Returns UIRouterPlugin[]

  - Defined in router.ts:210

- plugin<T>(plugin: object, options?: any): T

- Add plugin (as ES6 class)

- plugin<T>(plugin: function, options?: any): T

- Add plugin (as javascript constructor function)

- plugin<T>(plugin: PluginFactory<T>, options?: any): T

- Add plugin (as javascript factory function)

- Add plugin (as ES6 class)

  This method adds a UI-Router Plugin. A plugin can enhance or change UI-Router behavior using any public API.

  #### Example:

      import { MyCoolPlugin } from "ui-router-cool-plugin";

      var plugin = router.addPlugin(MyCoolPlugin);

  ### Plugin authoring

  A plugin is simply a class (or constructor function) which accepts a UIRouter instance and (optionally) an options object.

  The plugin can implement its functionality using any of the public APIs of UIRouter. For example, it may configure router options or add a Transition Hook.

  The plugin can then be published as a separate module.

  #### Example:

      export class MyAuthPlugin implements UIRouterPlugin {
        constructor(router: UIRouter, options: any) {
          this.name = "MyAuthPlugin";
          let $transitions = router.transitionService;
          let $state = router.stateService;

          let authCriteria = {
            to: (state) => state.data && state.data.requiresAuth
          };

          function authHook(transition: Transition) {
            let authService = transition.injector().get('AuthService');
            if (!authService.isAuthenticated()) {
              return $state.target('login');
            }
          }

          $transitions.onStart(authCriteria, authHook);
        }
      }

  #### Type parameters

  - #### T: UIRouterPlugin

  #### Parameters

  - ##### plugin object

    :

    one of:

           - a plugin class which implements <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a>
           - a constructor function for a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> which accepts a <a href="core.uirouter.html">UIRouter</a> instance
           - a factory function which accepts a <a href="core.uirouter.html">UIRouter</a> instance and returns a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> instance

    - ##### constructor: function

      - new __type(router: UIRouter, options?: any): T

      - #### Parameters

        - ##### router UIRouter

        - ##### options: Optional any

        #### Returns T

        - Defined in router.ts:135

  - ##### options: Optional any

    :

    options to pass to the plugin class/factory

  #### Returns T

  :

  the registered plugin instance

  - Defined in router.ts:135

- Add plugin (as javascript constructor function)

  This method adds a UI-Router Plugin. A plugin can enhance or change UI-Router behavior using any public API.

  #### Example:

      import { MyCoolPlugin } from "ui-router-cool-plugin";

      var plugin = router.addPlugin(MyCoolPlugin);

  ### Plugin authoring

  A plugin is simply a class (or constructor function) which accepts a UIRouter instance and (optionally) an options object.

  The plugin can implement its functionality using any of the public APIs of UIRouter. For example, it may configure router options or add a Transition Hook.

  The plugin can then be published as a separate module.

  #### Example:

      export class MyAuthPlugin implements UIRouterPlugin {
        constructor(router: UIRouter, options: any) {
          this.name = "MyAuthPlugin";
          let $transitions = router.transitionService;
          let $state = router.stateService;

          let authCriteria = {
            to: (state) => state.data && state.data.requiresAuth
          };

          function authHook(transition: Transition) {
            let authService = transition.injector().get('AuthService');
            if (!authService.isAuthenticated()) {
              return $state.target('login');
            }
          }

          $transitions.onStart(authCriteria, authHook);
        }
      }

  #### Type parameters

  - #### T: UIRouterPlugin

  #### Parameters

  - ##### plugin function

    :

    one of:

           - a plugin class which implements <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a>
           - a constructor function for a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> which accepts a <a href="core.uirouter.html">UIRouter</a> instance
           - a factory function which accepts a <a href="core.uirouter.html">UIRouter</a> instance and returns a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> instance

    - - (router: UIRouter, options?: any): void

      - #### Parameters

        - ##### router UIRouter

        - ##### options: Optional any

        #### Returns void

  - ##### options: Optional any

    :

    options to pass to the plugin class/factory

  #### Returns T

  :

  the registered plugin instance

  - Defined in router.ts:137

- Add plugin (as javascript factory function)

  This method adds a UI-Router Plugin. A plugin can enhance or change UI-Router behavior using any public API.

  #### Example:

      import { MyCoolPlugin } from "ui-router-cool-plugin";

      var plugin = router.addPlugin(MyCoolPlugin);

  ### Plugin authoring

  A plugin is simply a class (or constructor function) which accepts a UIRouter instance and (optionally) an options object.

  The plugin can implement its functionality using any of the public APIs of UIRouter. For example, it may configure router options or add a Transition Hook.

  The plugin can then be published as a separate module.

  #### Example:

      export class MyAuthPlugin implements UIRouterPlugin {
        constructor(router: UIRouter, options: any) {
          this.name = "MyAuthPlugin";
          let $transitions = router.transitionService;
          let $state = router.stateService;

          let authCriteria = {
            to: (state) => state.data && state.data.requiresAuth
          };

          function authHook(transition: Transition) {
            let authService = transition.injector().get('AuthService');
            if (!authService.isAuthenticated()) {
              return $state.target('login');
            }
          }

          $transitions.onStart(authCriteria, authHook);
        }
      }

  #### Type parameters

  - #### T: UIRouterPlugin

  #### Parameters

  - ##### plugin PluginFactory<T>

    :

    one of:

           - a plugin class which implements <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a>
           - a constructor function for a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> which accepts a <a href="core.uirouter.html">UIRouter</a> instance
           - a factory function which accepts a <a href="core.uirouter.html">UIRouter</a> instance and returns a <a href="../interfaces/core.uirouterplugin.html">UIRouterPlugin</a> instance

  - ##### options: Optional any

    :

    options to pass to the plugin class/factory

  #### Returns T

  :

  the registered plugin instance

  - Defined in router.ts:139

Generated using TypeDoc