![]() |
VOOZH | about |
In Angular 8, event binding is used to handle the events raised by the user actions like button click, mouse movement, keystrokes, etc. When the DOM event happens at an element(e.g. click, keydown, keyup), it calls the specified method in the particular component.
Using Event Binding we can bind data from DOM to the component and hence can use that data for further purposes.
Syntax:
< element (event) = function() >
Approach:
Example 1: Using click event on the input element.
app.component.html
app.component.ts
Output:
👁 ImageExample 2: Using keyup event on the input element.
app.component.html
app.component.ts
Output:
👁 Image