I'm trying to listen to the X position of my mouse in an Angular2 Directive like this:
@HostListener('mousemove', ['$event'])
onMousemove(event: Event): void {
console.log(event.clientX)
}
but I get the error
Property 'clientX' does not exist on type 'Event'.
This is odd because this listener
@HostListener('mousemove', ['$event'])
onMousemove(event: Event): void {
console.log(event)
}
logs out an event object
Why can I not access event.clientX
?
Change the parameter type
onMousemove(event: MouseEvent): void {
console.log(event.clientX)
}