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');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With