UIRouter | @uirouter/angular
Options
All
  • Public
  • Public/Protected
  • All
Menu

An instance of UI-Router.

This object contains references to service APIs which define your application's routing behavior.

Hierarchy

  • UIRouter

Index

Properties

globals

globals: UIRouterGlobals = new UIRouterGlobals()

An object that contains global router state, such as the current state and params

locationConfig

locationConfig: LocationConfig

a LocationConfig implementation

locationService

locationService: LocationServices

a LocationServices implementation

stateRegistry

stateRegistry: StateRegistry = new StateRegistry(this)

Provides a registry for states, and related registration services

stateService

stateService: StateService = new StateService(this)

Provides services related to states

trace

trace: Trace = trace

Enable/disable tracing to the javascript console

transitionService

transitionService: TransitionService = new TransitionService(this)

A service that exposes global Transition Hooks

urlMatcherFactory

urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory(this)

Deprecated for public use. Use urlService instead.

deprecated

Use urlService instead

urlRouter

urlRouter: UrlRouter = new UrlRouter(this)

Deprecated for public use. Use urlService instead.

deprecated

Use urlService instead

urlService

urlService: UrlService = new UrlService(this)

Provides services related to the URL

viewService

viewService: ViewService = new ViewService(this)

Provides services related to ui-view synchronization

Methods

disposable

getPlugin

plugin

  • plugin<T>(plugin: { constructor: any }, options?: any): T
  • plugin<T>(plugin: (router: UIRouter, options?: any) => void, options?: any): T
  • plugin<T>(plugin: PluginFactory<T>, options?: any): T
  • 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

    Parameters

    Returns T

    the registered plugin instance

  • 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

    Parameters

    • plugin: (router: UIRouter, options?: any) => void
        • (router: UIRouter, options?: any): void
        • Parameters

          • router: UIRouter
          • Optional options: any

          Returns void

    • Optional options: any

    Returns T

    the registered plugin instance

  • 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

    Parameters

    • plugin: PluginFactory<T>
    • Optional options: any

    Returns T

    the registered plugin instance

Generated using TypeDoc