I am using ViewChild in Angular 2 to isolate an element. I can directly manipulate styles, but I canβt find the documentation if you can change the element's style class.
This is a sample code:
export class HomeComponent implements OnInit { @ViewChild('slideBg') el:ElementRef; ngAfterViewInit { // style can be changed this.el.nativeElement.style.background = 'red'; // does not work: this.el.nativeElement.class = 'myCSSclass'; } β¦ }
See if this is possible and how. Any help was appreciated.
source share