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`** in Angular is an object that gives direct access to a component's or directive's DOM element through the `nativeElement` property. **Key point:** ElementRef gives direct access to the real DOM element, but its use should be limited so as not to violate Angular's principles and security (XSS).Shown above the full answer for quick recall.Answer (EN)Image`ElementRef` in Angular is an object that gives direct access to a **component's or directive's DOM element** through the `nativeElement` property. Uses: 1. Lets you read or change DOM element properties, for example `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 so as not to violate Angular's principles and security (XSS).For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.