ComponentRef

class

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

Overview

class ComponentRef<C> {
  get location: ElementRef
  get injector: Injector
  get instance: C
  get hostView: ViewRef
  get changeDetectorRef: ChangeDetectorRef
  get componentType: Type<any>
  destroy(): void
  onDestroy(callback: Function): void
}

Description

Represents an instance of a Component created via a ComponentFactory.

ComponentRef provides access to the Component Instance as well other objects related to this Component Instance and allows you to destroy the Component Instance via the destroy method.

Members

get location: ElementRef

Location of the Host Element of this Component Instance.

get injector: Injector

The injector on which the component instance exists.

get instance: C

The instance of the Component.

get hostView: ViewRef

The ViewRef of the Host View of this Component instance.

get changeDetectorRef: ChangeDetectorRef

The ChangeDetectorRef of the Component instance.

get componentType: Type<any>

The component type.

destroy(): void

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

onDestroy(callback: Function): void

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

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/ComponentRef