EventListener
<div
(name)="$observer"
></div>
To listen to events emitted by an element, sent to an Observer<Event>
, write (name)
, where name
is the type of this Event.
It's converted to something similar to this:
node.addEventListener('name', $observer);
Example​
<div
(click)="(event) => console.log(event)"
></div>
when the user clicks on the div -> output:
MouseEvent
Alternative syntax​
<div
on-click="$observer"
></div>
Instead of using parentheses you may prefix the event's type with on-
.