This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

NgModuleRef

npm Package @angular/core
Module import { NgModuleRef } from '@angular/core';
Source core/src/linker/ng_module_factory.ts

Overview

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

Description

Represents an instance of an NgModule created via a NgModuleFactory.

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

Members

      
      get injector: Injector
    

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


      
      get componentFactoryResolver: ComponentFactoryResolver
    

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


      
      get instance: T
    

The NgModule instance.


      
      destroy(): void
    

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


      
      onDestroy(callback: () => void): void
    

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