downgradeModule
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:
NgModuleFactory
: If you pass anNgModuleFactory
, it will be used to instantiate a module usingplatformBrowser
'sbootstrapModuleFactory()
. NOTE: this type of the argument is deprecated. Please either provide anNgModule
class or a bootstrap function instead.NgModule
class: If you pass an NgModule class, it will be used to instantiate a module usingplatformBrowser
'sbootstrapModule()
.Function
: If you pass a function, it is expected to return a promise resolving to anNgModuleRef
. The function is called with an array of extraProviders
that are expected to be available from the returnedNgModuleRef
'sInjector
.
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.
string
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:
NgModuleFactory
: If you pass anNgModuleFactory
, it will be used to instantiate a module usingplatformBrowser
'sbootstrapModuleFactory()
. NOTE: this type of the argument is deprecated. Please either provide anNgModule
class or a bootstrap function instead.NgModule
class: If you pass an NgModule class, it will be used to instantiate a module usingplatformBrowser
'sbootstrapModule()
.Function
: If you pass a function, it is expected to return a promise resolving to anNgModuleRef
. The function is called with an array of extraProviders
that are expected to be available from the returnedNgModuleRef
'sInjector
.
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.
string