I noticed that with Angular 2, unlike the documentation, when I bind an event, I do not need to pass $ event to access event data from the component. Thus, the following code works fine:
In the template:
<h2 (mouseover)="getCoord()" >Random Words</h2>
In component:
getCoord() {
console.log(event.clientX + ", " + event.clientY);
}
This works fine, without having to pass the $ event object through the method.
This is normal? This is the preferred method, but the documentation does not show it? Seems good to me.
source
share