Event handler parameters in Angular template
You can pass parameters to event handler methods. Let's pass a string, for example:
<button (click)="show('test')">
button
</button>
In the component class method, we set the parameter, indicating its string type:
export class AppComponent {
public show(arg: string): void {
alert(arg);
}
}
When you click the button, pass two numbers as a method parameter. In the method, output the sum of these numbers to the console.