"src/lazyLoad/lazyLoadNgModule" | @uirouter/angular
Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "src/lazyLoad/lazyLoadNgModule"

Index

Type aliases

Functions

Type aliases

ModuleTypeCallback

ModuleTypeCallback: () => Type<any> | Promise<Type<any>>

A function that returns an NgModule, or a promise for an NgModule

Example:

export function loadFooModule() {
  return import('../foo/foo.module').then(result => result.FooModule);
}

Type declaration

    • (): Type<any> | Promise<Type<any>>
    • Returns Type<any> | Promise<Type<any>>

Functions

loadNgModule

  • loadNgModule(moduleToLoad: ModuleTypeCallback): (transition: Transition, stateObject: StateDeclaration) => Promise<LazyLoadResult>
  • Returns a function which lazy loads a nested module

    This is primarily used by the ng2LazyLoadBuilder when processing Ng2StateDeclaration.loadChildren.

    It could also be used manually as a [[StateDeclaration.lazyLoad]] property to lazy load an NgModule and its state(s).

    Example:

    Using import() and named export of HomeModule

    declare var System;
    var futureState = {
      name: 'home.**',
      url: '/home',
      lazyLoad: loadNgModule(() => import('./home/home.module').then(result => result.HomeModule))
    }

    Example:

    Using a path (string) to the module

    var futureState = {
      name: 'home.**',
      url: '/home',
      lazyLoad: loadNgModule('./home/home.module#HomeModule')
    }

    Parameters

    • moduleToLoad: ModuleTypeCallback

      a path (string) to the NgModule to load. Or a function which loads the NgModule code which should return a reference to the NgModule class being loaded (or a Promise for it).

    Returns (transition: Transition, stateObject: StateDeclaration) => Promise<LazyLoadResult>

    A function which takes a transition, which:

    • 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
      • (transition: Transition, stateObject: StateDeclaration): Promise<LazyLoadResult>
      • Parameters

        • transition: Transition
        • stateObject: StateDeclaration

        Returns Promise<LazyLoadResult>

Generated using TypeDoc