Search code examples
cssionic5

How to add an animation on Ionic 5 once click on a button?


My code is the following, but it doesn't work, what i want is to activate the effect once button clicked. //TS

@ViewChild('icono', { read: ElementRef })icono: ElementRef;

execEffect() {
    let x = this.icono
    x.nativeElement.classList.add('bounce')
}

//HTML

<img #icono src="../../assets/something.png" style="width:60px;" (click)="execEffect()"/>

Solution

  • I recommend you to use Renderer 2...

    I made and example four you...

    https://stackblitz.com/edit/angular-ivy-bsqd5d