0
追加する|角度要素でcssクラスを削除しますか?追加するには|角度要素でcssクラスを削除しますか?
角度要素へのアクセスは、this.elementRef.nativeElement
(import { ElementRef } from '@angular/core';
)です。 CSSクラス名はmyclass
です。
追加する|角度要素でcssクラスを削除しますか?追加するには|角度要素で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');
}
をaddClassを使用して
import {Component, HostBinding} from "@angular/core";
@Component({
...
})
export class myComponent {
@HostBinding('class.myclass') visible: boolean = false; // True when visible
}