ElementRef
class
npm Package | @angular/core |
---|---|
Module | import { ElementRef } from '@angular/core'; |
Source | core/src/linker/element_ref.ts |
Security Risk
Permitting direct access to the DOM can make your application more vulnerable to XSS attacks. Carefully review any use of ElementRef
in your code. For more detail, see the Security Guide.
Overview
class ElementRef { constructor(nativeElement: any) nativeElement: any }
Constructor
constructor(nativeElement: any)
Members
nativeElement: any
The underlying native element or null
if direct access to native elements is not supported (e.g. when the application runs in a web worker).
Use this API as the last resort when direct access to DOM is needed. Use templating and data-binding provided by Angular instead. Alternatively you take a look at Renderer
which provides API that can safely be used even when direct access to native elements is not supported.
Relying on direct DOM access creates tight coupling between your application and rendering layers which will make it impossible to separate the two and deploy your application into a web worker.
© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v4.angular.io/api/core/ElementRef