At the following example, we bind a
click-event to a
button-element to fire the
onDelete()-method of the Angular component.
<button (click)="onDelete()"> 🗑️ </button>
When you click the
<button> from the example, a click
event is rising and the
onDelete()-method is executed.
You write that method in the class of your
As a taget event name you can specify pretty much any event. You simply have to wrap the event name into a pair of parentheses
(…). For example
(change) or (focus).
A complete list of possible DOM events can be found here: HTML DOM Events.
Note that you can also create your own events with custom event names using
EventEmitter. Details on that can be found here: Custom events with EventEmitter.
For more details on event binding check out the docs.