• Overview
@angular/upgrade/static

downgradeModule

function

A helper function for creating an AngularJS module that can bootstrap an Angular module "on-demand" (possibly lazily) when a downgraded component needs to be instantiated.

  
    
  
  
function downgradeModule<T>(moduleOrBootstrapFn: Type<T> | ((extraProviders: StaticProvider[]) => Promise<NgModuleRef<T>>)): string;

A helper function for creating an AngularJS module that can bootstrap an Angular module "on-demand" (possibly lazily) when a downgraded component needs to be instantiated.

Part of the upgrade/static library for hybrid upgrade apps that support AOT compilation.

It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to pay the cost up-front. For example, you can have an AngularJS application that uses Angular for specific routes and only instantiate the Angular modules if/when the user visits one of these routes.

The Angular module will be bootstrapped once (when requested for the first time) and the same reference will be used from that point onwards.

downgradeModule() requires either an NgModuleFactory, NgModule class or a function:

downgradeModule() returns the name of the created AngularJS wrapper module. You can use it to declare a dependency in your main AngularJS module.

{@example upgrade/static/ts/lite/module.ts region="basic-how-to"}

For more details on how to use downgradeModule() see Upgrading for Performance.

@parammoduleOrBootstrapFnType<T> | ((extraProviders: StaticProvider[]) => Promise<NgModuleRef<T>>)
@returnsstring
function downgradeModule<T>(moduleOrBootstrapFn: NgModuleFactory<T>): string;

A helper function for creating an AngularJS module that can bootstrap an Angular module "on-demand" (possibly lazily) when a downgraded component needs to be instantiated.

Part of the upgrade/static library for hybrid upgrade apps that support AOT compilation.

It allows loading/bootstrapping the Angular part of a hybrid application lazily and not having to pay the cost up-front. For example, you can have an AngularJS application that uses Angular for specific routes and only instantiate the Angular modules if/when the user visits one of these routes.

The Angular module will be bootstrapped once (when requested for the first time) and the same reference will be used from that point onwards.

downgradeModule() requires either an NgModuleFactory, NgModule class or a function:

downgradeModule() returns the name of the created AngularJS wrapper module. You can use it to declare a dependency in your main AngularJS module.

{@example upgrade/static/ts/lite/module.ts region="basic-how-to"}

For more details on how to use downgradeModule() see Upgrading for Performance.

@deprecated

Passing NgModuleFactory as the downgradeModule function argument is deprecated, please pass an NgModule class reference instead.

@parammoduleOrBootstrapFnNgModuleFactory<T>
@returnsstring
Jump to details