Options
Menu

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

UI-Router (for a 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 stateRegistry.

Tell UI-Router to monitor the URL by calling uiRouter.urlRouter.listen() (UrlRouter.listen)

Hierarchy

  • UIRouter

Index

Constructors

Properties

_disposables: Disposable[] = []
globals: UIRouterGlobals = new Globals(this.transitionService)
locationConfig: LocationConfig
locationService: LocationServices
stateRegistry: StateRegistry = new StateRegistry(this)
stateService: StateService = new StateService(this)
transitionService: TransitionService = new TransitionService(this)
urlMatcherFactory: UrlMatcherFactory = new UrlMatcherFactory()
urlRouter: UrlRouter = new UrlRouter(this)
urlService: UrlService = new UrlService(this)
viewService: ViewService = new ViewService()

Methods

  • disposable(disposable: Disposable): void
  • Registers an object to be notified when the router is disposed

  • 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


  • plugin<T>(plugin: object, options?: any): T
  • Adds a plugin to UI-Router

  • plugin<T>(plugin: function, options?: any): T
  • Allow javascript constructor function

  • plugin<T>(plugin: PluginFactory, options?: any): T
  • Allow javascript factory function

  • Adds a plugin to UI-Router

    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 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
      
    • options: Optional  any
      :

      options to pass to the plugin class/factory

    Returns T

    :

    the registered plugin instance


  • Allow javascript constructor function

    Type parameters

    Parameters

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

          • router UIRouter
          • options: Optional  any

          Returns void

    • options: Optional  any

    Returns T


  • Allow javascript factory function

    Type parameters

    Parameters

    Returns T


Generated using TypeDoc