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

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

Hierarchy

Index

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 deferInitialRender

deferInitialRender: boolean

Tells Angular to defer the first render until after the initial transition is complete.

When true, adds an async APP_INITIALIZER which is resolved after any onSuccess or onError. The initializer stops angular from rendering the root component until after the first transition completes. This may prevent initial page flicker while the state is being loaded.

Defaults to false

Optional deferIntercept

deferIntercept: boolean

Sets [[UrlRouterProvider.deferIntercept]]

Optional initial

initial: string | UrlRuleHandlerFn | TargetState | TargetStateDef

Configures the initial rule, which chooses the state or URL to activate when the application initially starts, and no other routes matched.

See: [[UrlRulesApi.initial]].

Optional otherwise

otherwise: string | UrlRuleHandlerFn | TargetState | TargetStateDef

Configures the otherwise rule, which chooses the state or URL to activate when no other routes matched.

See: [[UrlRulesApi.otherwise]].

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.

Optional useHash

useHash: boolean

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