Property 'clientX' does not exist on type 'Event'. Angular2 Directive

Discussão em 'Angular' iniciado por Nate May, Dezembro 17, 2024.

  1. Nate May

    Nate May Guest

    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

    [​IMG]

    Why can I not access event.clientX?

    Continue reading...

Compartilhe esta Página