Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add css class on click in Angular 6

I want add animation class continuously on clicking for that I have written below code

My Code

My problem is when I click first time then only first time animation works on second click animation not working. Please help.

like image 814
vedankita kumbhar Avatar asked Dec 28 '25 23:12

vedankita kumbhar


1 Answers

You can add setTimeout for delay to add add class

Stackblitz Demo

rotate(event){
    event.srcElement.classList.remove("rotate");
    setTimeout(()=>{
      event.srcElement.classList.add("rotate");
    },0)
  }
like image 138
Krishna Rathore Avatar answered Dec 30 '25 16:12

Krishna Rathore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!