showing results for - "addclass to elementref angular"
Niclas
30 Nov 2017
1export class CustomDirective {
2
3   constructor(private renderer: Renderer2,
4               private elementRef: ElementRef,
5               service: SomService) {
6   }
7
8   addClass(className: string, element: any) {
9       this.renderer.addClass(element, className);
10       // or use the host element directly
11       // this.renderer.addClass(this.elementRef.nativeElement, className);
12   }
13
14   removeClass(className: string, element: any) {
15       this.renderer.removeClass(element, className);
16   }
17
18}
19