1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Angular using MouseEvent instead of PointerEvent it TypeScript

Discussão em 'Angular' iniciado por Sajjad-Kazemi, Julho 5, 2025.

  1. When I started learning AngularJs i ran into something weird in a component when i write a click event and get send the $event as the parameter the type of event has to be MouseEvent in the TS file, but there is one problem! The event actually is a PointerEvent and if I set the type of the event as PointerEvent the angular throws this error!

    counter.ts

    import { Component } from '@angular/core';

    @Component({
    selector: 'app-counter',
    imports: [],
    templateUrl: './counter.html',
    styleUrl: './counter.css'
    })
    export class Counter {
    counter: number = 0;

    changeValue(event:pointerEvent,value: number): void {
    this.counter += value;
    }
    }


    counter.html

    <h3>
    {{counter}}
    </h3>
    <button (click)="changeValue($event,1)">Increment</button>
    <button (click)="changeValue($event,-1)">Decrement</button>


    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página