Reputation: 198
I am using angular $event in one of my function as a parameter. I don't want to use 'any' type for evt in function definition. what is the preferable alternative for evt?
Html
<button class="edit-button" (click)="invokeEdit($event)">Edit</button>
TypeScript
public invokeEdit(evt: any): void {
evt.stopPropagation();
}
Upvotes: 0
Views: 283
Reputation: 2470
You can use the mouse event MouseEvent interface. Please check the below link for more information.
Html:-
<button (click)="invokeEdit($event)" type="submit" mat-raised-button color="default">Edit</button>
TypeScript:-
public invokeEdit(event: MouseEvent): void {
console.log(event);
event.stopPropagation();
}
Upvotes: 2