## 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` 允許注冊將在組件銷毀時調用的回調。
- 說明
- angular 1.x
- ngModelController
- ngOptions
- ngModelOptions
- lifecycle
- directive
- angular 2
- @angular/forms
- 類
- AbstractControl
- AbstractControlDirective
- AbstractFormGroupDirective
- FormControl
- FormArray
- FormBuilder
- FormGroup
- NgControl
- 接口
- controlValueAccessor
- 指令
- DefaultValueAccessor
- Angular 2 生命周期
- OnInit
- DoCheck
- @angular/router
- 配置
- Routes
- 指令
- RouterOutlet
- RouterLink
- 接口
- ActivatedRoute
- UrlTree
- NavigationExtras
- ActivatedRouteSnapshot
- RouterStateSnapshot
- 類
- UrlSegment
- UrlSegmentGroup
- UrlSerializer
- DefaultUrlSerializer
- Router
- bug記得
- @angular/http
- 類
- Http
- Body
- Response
- ResponseOptions
- Header
- Request
- RequestOptions
- URLSearchParams
- @angular/core
- decorator
- Component-decorator
- animation
- DI
- linker
- TemplateRef
- ElementRef
- EmbeddedViewRef
- ViewRef
- ViewContainerRef
- Query
- ComponentFactory
- ComponentRef
- Renderer
- change_detection
- KeyValueDiffers
- IterableDiffers
- ChangeDetectorRef
- ChangeDetectionStrategy
- Zone
- ngZone
- @angular/common
- 指令
- NgTemplateOutlet
- QueryList
- bootstrap4
- card
- form
- 重點關注博客
- 學習過的文章
- 筆記
- Angular 2 雙向綁定
- 將字符串解析成DOM
- rx相關
- operators
- combineLatest
- combineAll
- concat(All, Map, *MapTo)
- 背壓(backpressure)
- js事件keycode對應表
- 裝飾器
- 有用的代碼摘錄
- 日期操作
- 數量操作
- 字符操作
- rxjs問題
- 小示例
- h5面試準備
- react
- 開發遇到的問題