Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TS7006: Parameter 'event' implicitly has an 'any' type

In angular,

This is script

<button (click)="onClick($event)"> Greet </button>
     <button (click)="greeting='welcome' "> Greet </button> 
     {{greeting}}

This is event Logic

public greeting =""; 
 onClick(event) {
    console.log(event);
   this.greeting ='welcome';
  }
like image 958
Prasad Avatar asked Feb 01 '26 20:02

Prasad


1 Answers

Some alternatives you can use:

onClick(event: Event) {}

onClick(event: MouseEvent) {}

Also, if you are not using the parameter event for anything, you can remove it.

onClick() { ... }
like image 108
richlira Avatar answered Feb 04 '26 08:02

richlira



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!