Angular 2 event bindings - Do I need $ event?

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.

+4
source share
1 answer

I would think that this is a bug in Angular and would not work on it to continue to work.

, , @HostListener(), args, , $event $event.target - .

WebWorker , , args. , - , .

+3

All Articles