## ElementRef
允許對DOM的直接訪問可能會使您的應用程序更容易受到XSS攻擊。 仔細查看您的代碼中使用`ElementRef`。 有關詳細信息,請參閱“[安全指南](http://g.co/ng/security)”。
### 類定義
```typescript
class ElementRef {
constructor(nativeElement: any)
nativeElement : any
}
```
### 屬性
- nativeElement : `any`
如果不支持對原生元素的直接訪問(例如,當應用程序在Web worker中運行時),則為底層原生元素或null。
> 使用此API作為最后的手段,當需要直接訪問DOM。 使用Angular提供的模板和數據綁定。 或者,您可以查看`Renderer`,它提供了可以安全使用的API,即使不支持直接訪問原生元素。
> 依賴于直接DOM訪問在應用程序和呈現層之間創建緊密的耦合,這將使得不可能分離兩者并將應用程序部署到Web worker中。
- 說明
- 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
- 開發遇到的問題