Event Binding
- Flows data from an element to the component
- Created with parentheses
<button (click)=”foo($event)”></button> - Information about the target event is carried in the $event parameter
<button (click)="handleClickEvent()">Test</button>
<button type="button" (click)="saved.emit(selectedItem)">Save</button
So, instead of using JavaScript to listen to onClick event manually, you can listen to it using (click) (i.e. without on) and when that event triggers, you can execute some logic, which in this case is calling a function handleClickEvent() defined in the Components class.
Backlinks