How to add | remove css class in angular element?
Access to angular element is via: this.elementRef.nativeElement
(import { ElementRef } from '@angular/core';
). CSS class name is myclass
.
constructor(public elementRef: ElementRef, private renderer: Renderer)
{
this.renderer.setElementClass(this.elementRef, 'class');
// or
this.elementRef.nativeElement.classList.add('class');
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments