To set a specific action in button event, we use the event binding syntax. In this post we will see how to set this on a button.

Syntaxe :

<button (click)="save()">Save</button>

The event binding will listens for the button’s click events and calls the component’s save() method whenever a click occurs.

(click) : when the user click on the button we will execute the function.