ViewRef

Represents an Angular view, specifically the host view that is defined by a component. Also serves as the base class that adds destroy methods for embedded views.

      
      abstract class ViewRef extends ChangeDetectorRef {
  abstract destroyed: boolean
  abstract destroy(): void
  abstract onDestroy(callback: Function): any

  // 继承自 core/ChangeDetectorRef
  abstract markForCheck(): void
  abstract detach(): void
  abstract detectChanges(): void
  abstract checkNoChanges(): void
  abstract reattach(): void
}
    

参见

属性

属性说明
abstract destroyed: boolean 只读

Reports whether this view has been destroyed.

方法

Destroys this view and all of the data structures associated with it.

abstract destroy(): void
      
      abstract destroy(): void
    
参数

没有参数。

返回值

void

A lifecycle hook that provides additional developer-defined cleanup functionality for views.

abstract onDestroy(callback: Function): any
      
      abstract onDestroy(callback: Function): any
    
参数
callback Function

A handler function that cleans up developer-defined data associated with a view. Called when the destroy() method is invoked.

返回值

any