RootModule | ui-router-ng2

Interface RootModule

UI-Router declarative configuration which can be provided to UIRouterModule.forRoot




config: function

A UI-Router Module's imperative configuration

A UI-Router Module's imperative configuration

If a UI-Router Module needs to perform some configuration (such as registering parameter types or Transition Hooks) a configFn should be supplied. The function will be passed the UIRouter instance and the module's Injector


import { Injector } from "@angular/core";
import { UIRouter } from "ui-router-ng2";
import { requireAuthHook } from "./requireAuthHook";
import { MyService } from "./myService";

export function configureMyModule(uiRouter: UIRouter, injector: Injector) {
  // Get UIRouter services off the UIRouter object
  let urlConfig = uiRouter.urlService.config;
  let transitionService = uiRouter.transitionService;

  transitionService.onBefore({ to: (state) => state.requiresAuth }, requireAuthHook);

  // Create a slug type based on the string type
  let builtInStringType = urlConfig.type('string');
  let slugType = Object.assign({}, builtInStringType, { encode: (str) => str, decode: (str) => str });
  urlConfig.type('slug', slugType);

  // Inject arbitrary services from DI using the Injector argument
  let myService: MyService = injector.get(MyService)



({ imports: [ UIRouterModule.forChild({ states: STATES, config: configureMyModule }); ] }) class MyModule {} ```

Type declaration

    • (uiRouterInstance: UIRouter, injector: Injector): any
    • Parameters

      • uiRouterInstance UIRouter
      • injector Injector

      Returns any

deferIntercept: boolean

Sets [[UrlRouterProvider.deferIntercept]]

Sets [[UrlRouterProvider.deferIntercept]]

otherwise: string | TargetState | UrlRuleHandlerFn | TargetStateDef

Sets [[UrlRouterProvider.otherwise]].

Sets [[UrlRouterProvider.otherwise]].

states: Ng2StateDeclaration[]

The module's UI-Router states

The module's UI-Router states

This list of Ng2StateDeclaration objects will be registered with the StateRegistry. Also, the components that the states route to will be added to entryComponents so they will be compiled.

useHash: boolean

Chooses a LocationStrategy.

Chooses a LocationStrategy.

The location strategy enables either HTML5 Push State (Requires server-side support) or "HashBang" URLs.

When false, uses PathLocationStrategy When true, uses HashLocationStrategy

Defaults to false

Generated using TypeDoc