如何添加 | 删除角度元素中的css类?
访问角度元素是通过:this.elementRef.nativeElement
( import { ElementRef } from '@angular/core';
)。CSS 类名称是myclass
.
constructor(public elementRef: ElementRef, private renderer: Renderer)
{
this.renderer.setElementClass(this.elementRef, 'class');
// or
this.elementRef.nativeElement.classList.add('class');
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句