Angular Master (283 Qs)•Part 8: Internationalization (i18n), Testing & DOM Directives (177 - 212)
How do you select an element in component template?
mid LevelCode ExampleDirectivesComponentsTesting
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';
}