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

UI-Router Module declarative configuration which can be passed to UIRouterModule.forChild

Hierarchy

Index

Properties

Properties

Optional config

config: (uiRouterInstance: UIRouter, injector: Injector, module: StatesModule) => any

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, the module's Injector, and the module object.

Example:

import { Injector } from "@angular/core";
import { UIRouter } from "@uirouter/angular";
import { requireAuthHook } from "./requireAuthHook";
import { MyService } from "./myService";

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

  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)
  myService.useFastMode();
}
@NgModule({
  imports: [
    UIRouterModule.forChild({ states: STATES, config: configureMyModule });
  ]
})
class MyModule {}

Type declaration

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

      • uiRouterInstance: UIRouter
      • injector: Injector
      • module: StatesModule

      Returns any

Optional 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.

Generated using TypeDoc