I wanted to know what is difference between this code:
export class SomeDirective implements OnInit {
constructor(private _elRef: ElementRef){}
ngOnInit(): any {
this._elRef.nativeElement.style.backgroundColor = 'green';
}
}
and this one:
export class SomeDirective implements OnInit {
constructor(private _elRef: ElementRef, private _renderer: Renderer){}
ngOnInit(): any {
this._renderer.setElementStyle(this._elRef, 'background-color', 'green');
}
}
I know that the second one has some advantages over the first one, I just need to know what those advantages specifically are.