企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## ComponentRef 表示通过ComponentFactory创建的组件的实例。 `ComponentRef`提供对组件实例的访问以及与此组件实例相关的其他对象,并允许您通过`destroy`方法销毁组件实例。 ### 类定义 ```typescript class ComponentRef { C location : ElementRef injector : Injector instance : C hostView : ViewRef changeDetectorRef : ChangeDetectorRef componentType : Type<any> destroy() : void onDestroy(callback: Function) : void } ``` ### 属性 - C - location : `ElementRef` 组件实例的宿主元素所在的位置 - injector : `Injector` 组件实例存在的注射器 - instance : C 组件实例 - hostview : `ViewRef` 组件实例的宿主视图`ViewRef` - changeDetectorRef : `ChangeDetectorRef` 组件的ChangeDetectorRef - componentType: `Type<any>` 组件类型 - destroy() : `void` 销毁组件实例及其附加数据 - onDestroy(callback: `Function`) : `void` 允许注册将在组件销毁时调用的回调。