0 votes
in Angular by
How do you select an element in component template?

1 Answer

0 votes
by

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,

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