ng2 | UI-Router
Options
All
  • Public
  • Public/Protected
  • All
Menu

External module ng2

UI-Router for Angular 2

Getting started:

  • Use npm. Add a dependency on latest ui-router-ng2
  • Import UI-Router classes directly from "ui-router-ng2"
import {StateRegistry} from "ui-router-ng2";
export let state1: Ng2StateDeclaration = {
  name: 'state1',
  component: State1Component,
  url: '/one'
}

export let state2: Ng2StateDeclaration = {
  name: 'state2',
  component: State2Component,
  url: '/two'
}
@ NgModule({
  imports: [
    SharedModule,
    UIRouterModule.forChild({ states: [state1, state2 ] })
  ],
  declarations: [
    State1Component,
    State2Component,
  ]
})
export class MyFeatureModule {}
  • Import a UIRouterModule.forRoot module into your application root NgModule
  • Either bootstrap a UIView component, or add a <ui-view></ui-view> viewport to your root component.
@ NgModule({
  imports: [
    BrowserModule,
    UIRouterModule.forRoot({ states: [ homeState ] }),
    MyFeatureModule,
  ],
  declarations: [
    HomeComponent
  ]
  bootstrap: [ UIView ]
})
class RootAppModule {}

browserPlatformDynamic.bootstrapModule(RootAppModule);
import {UIRouter} from "ui-router-ng2";

@ Injectable()
export class MyUIRouterConfig {
  // Constructor is injectable
  constructor(uiRouter: UIRouter) {
    uiRouter.urlMatcherFactory.type('datetime', myDateTimeParamType);
  }
}

Index

Type aliases

ReflectorReader: ReflectorReader

Variables

NG2_INJECTOR_TOKEN: OpaqueToken
UIROUTER_MODULE_TOKEN: OpaqueToken
UIROUTER_PROVIDERS: Provider[]

The UI-Router providers, for use in your application bootstrap

The UI-Router providers, for use in your application bootstrap

deprecated

use UIRouterModule.forRoot

UIROUTER_ROOT_MODULE: OpaqueToken
_UIROUTER_INSTANCE_PROVIDERS: Provider[]
_UIROUTER_SERVICE_PROVIDERS: Provider[]
id: number
reflector: Reflector
splitOnEquals: (Anonymous function)
splitOnHash: (Anonymous function)
splitOnQuestionMark: (Anonymous function)

Functions

  • applyModuleConfig(uiRouter: UIRouter, injector: Injector, options: StatesModule): void
  • applyRootModuleConfig(uiRouter: UIRouter, injector: Injector, config: RootModule): void
  • loadNgModule(path: string): function
  • Returns a function which lazy loads a nested module

  • Returns a function which lazy loads a nested module

    Use this function as a StateDeclaration.lazyLoad property to lazy load a state tree (an NgModule).

    Parameters

    • path: string
      :

      the path to the module source code.

    Returns function

    :

    A function which takes a transition, then:

    • Gets the Injector (scoped properly for the destination state)
    • Loads and creates the NgModule
    • Finds the "replacement state" for the target state, and adds the new NgModule Injector to it (as a resolve)

    returns the new states array


  • makeProviders(module: StatesModule, forRoot: boolean): Provider[]
  • uiRouterFactory(location: UIRouterLocation, injector: Injector): UIRouter
  • This is a factory function for a UIRouter instance

  • This is a factory function for a UIRouter instance

    Creates a UIRouter instance and configures it for Angular 2, then invokes router bootstrap. This function is used as an Angular 2 useFactory Provider.

    Parameters

    Returns UIRouter


Generated using TypeDoc