42

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,277
  • 3
  • 15
  • 19

1 Answers1

35

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
  • 623,577
  • 216
  • 2,003
  • 1,567
  • 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