Suggest an editImprove this articleRefine the answer for “What does ElementRef do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**ElementRef** is an object in Angular that provides direct access to the DOM element of a component or directive through the `nativeElement` property. **Key point:** using `ElementRef` should be limited to avoid violating Angular's principles and security (XSS).Shown above the full answer for quick recall.Answer (EN)Image`ElementRef` in Angular is an object that provides direct access to the **DOM element of a component or directive** through the `nativeElement` property. Usage: 1. Allows reading or modifying DOM element properties, such as `style`, `class`, `value`. 2. Used in directives to interact with the element they are applied to. Example: ```typescript import { Component, ElementRef, AfterViewInit } from '@angular/core'; @Component({ selector: 'app-example', template: `<p>Hello</p>` }) export class ExampleComponent implements AfterViewInit { constructor(private el: ElementRef) {} ngAfterViewInit() { this.el.nativeElement.style.color = 'red'; // change the text color } } ``` > Conclusion: `ElementRef` gives direct access to the real DOM element, but its use should be limited to avoid violating Angular's principles and security (XSS).For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.