Remove or add class in Angular

前端 未结 5 2023
感动是毒
感动是毒 2021-02-14 08:37

I have a list and the plugin (dragula) I used, adds certain CSS class on certain action. I am using Angular 5. I want to find out the presence of certain class (

5条回答
  •  温柔的废话
    2021-02-14 09:31

    You can use id in your html

    
    

    add viewchild in your.ts

    @ViewChild('namebutton') namebutton: ElementRef;
    

    create a function that will trigger the event

     actionButton() {
        this.namebutton.nativeElement.classList.add('class-to-add')
        setTimeout(() => {
          this.namebutton.nativeElement.classList.remove('class-to-remove')
        }, 1000);
      }
                  
    

    and call the function.

提交回复
热议问题