Help Angular by taking a 1 minute survey!Go to surveyHome

NgModuleRef

Represents an instance of an NgModule created via a NgModuleFactory.

See more...

      
      abstract class NgModuleRef<T> {
  abstract injector: Injector
  abstract componentFactoryResolver: ComponentFactoryResolver
  abstract instance: T
  abstract destroy(): void
  abstract onDestroy(callback: () => void): void
}
    

Description

NgModuleRef provides access to the NgModule Instance as well other objects related to this NgModule Instance.

Properties

Property Description
abstract injector: Injector Read-only.

The injector that contains all of the providers of the NgModule.

abstract componentFactoryResolver: ComponentFactoryResolver Read-only.

The ComponentFactoryResolver to get hold of the ComponentFactories declared in the entryComponents property of the module.

abstract instance: T Read-only.

The NgModule instance.

Methods

Destroys the module instance and all of the data structures associated with it.

abstract destroy(): void
      
      abstract destroy(): void
    
Parameters

There are no parameters.

Returns

void

Allows to register a callback that will be called when the module is destroyed.

abstract onDestroy(callback: () => void): void
      
      abstract onDestroy(callback: () => void): void
    
Parameters
callback () => void
Returns

void