Binding event handlers in an Angular template
In Angular, event handlers are attached to tags in a special way - using attributes. The event name is specified in parentheses, and the attribute value calls the component class method that should be executed by this event.
For example, let's make it so that when a button is clicked, the show method of the component class is executed:
<button (click)="show()">
button
</button>
Now let's write the implementation of the show method in the component class:
export class AppComponent {
public show(): void {
alert('test');
}
}
Make two buttons. When you click the first one, greet the user, and when you click the second one, say goodbye to him.