Looking to retrieve mouse coordinates in an Angular component.
This is the HTML snippet:
<div id="container" class="fullSize" style="height:100%;" (click)="onClick(ev)"></div>
And here's the corresponding function in the TypeScript file:
onClick( ev : MouseEvent ) {
console.log("x:" + ev.clientX);
}
The console shows this error:
Cannot read property 'clientX' of undefined'
How can I correctly pass the MouseEvent to my component function?