41

When I do this:

<div (click)="func1()" (dblclick)="func2()">Some text</h1>

I actually get "func1()" to fire even on dblclick twice.

How can I make it work on the same element and work good?

Teddy
  • 2,019
  • 3
  • 14
  • 19

1 Answers1

36

Doesn't seem to be an Angular issue. See https://css-tricks.com/snippets/javascript/bind-different-events-to-click-and-double-click/

The workaround is to not process the click event when a dblclick happens shortly afterwards.

Günter Zöchbauer
  • 558,509
  • 191
  • 1,911
  • 1,506
  • 3
    Nice one Gunter. Here is a [stackblitz](https://stackblitz.com/edit/angular-click-and-double-click-same-element) example using your technique. – Enrico Saunders May 13 '20 at 09:21