1
<span>
<a href="www....">
  (click)="function1()" dblclick="function2()
</a>
</span>

Need to go to the url only for double click.on single click should execute function1.Also because of <anchor tag with href, it goes to the site by default.

SHR
  • 7,940
  • 9
  • 38
  • 57
gacha
  • 103
  • 1
  • 9

1 Answers1

1

This is because angular run click event and does't encounter dblclick happens immidiatly afterwards. Seems this has to be resolved by timeout may be.

<span>
<a href="www...." (click)="function1()" (dblclick)="function2()">
  Check Event
</a>
</span>

toggle: Boolean = true;     

  function1(){
    this.toggle = true;
    setTimeout(()=>{
        if(this.toggle){
            console.log('Single click');
        }
    },250)
  }

  function2(){
    this.toggle = false;
    console.log('DBL click');
  }

Ref -

Working Example in Angular

Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215