Represents an instance of an NgModule created by an NgModuleFactory. Provides access to the NgModule instance and related objects.
API
abstract class NgModuleRef<T> {
abstract readonly injector: EnvironmentInjector;
abstract readonly componentFactoryResolver: ComponentFactoryResolver;
abstract readonly instance: T;
abstract destroy(): void;
abstract onDestroy(callback: () => void): void;
}
injector
EnvironmentInjectorThe injector that contains all of the providers of the NgModule.
componentFactoryResolver
ComponentFactoryResolverThe resolver that can retrieve component factories in a context of this module.
Note: since v13, dynamic component creation via ViewContainerRef.createComponent does not require resolving component factory: component class can be used directly.
instance
TThe NgModule instance.
destroy
voidDestroys the module instance and all of the data structures associated with it.
void
onDestroy
voidRegisters a callback to be executed when the module is destroyed.
() => void
void