InterviewHubPRO
Section Overview
Q191

Question 191 of 283

Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)

67%
Angular & Signals (283 Qs)•Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)

How do you select an element in component template?

You can control any DOM element via ElementRef by injecting it into your component's constructor. i.e, The component should have constructor with ElementRef parameter,

javascript
constructor(myElement: ElementRef) {
 el.nativeElement.style.backgroundColor = 'yellow';
}