# Ng-click fires twice in response to a single tap

**URL:** <https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585>\
**Category:** ionic-v1\
**Created:** [May 7, 2015, 11:21pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585 "2015-05-07T23:21:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfrumar](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jfrumar](https://forum.ionicframework.com/u/jfrumar)\
**Post date:** [May 7, 2015, 11:21pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/1 "2015-05-07T23:21:26Z")

</div>

We have an “expand” action that, once clicked, adds a bunch of new elements to the DOM. This is a bit slow on mobile devices, and is resulting in the Ionic Tap system triggering 2 ng-click events.

I have uncommented [line 2844](https://github.com/driftyco/ionic/blob/master/release%2Fjs%2Fionic.js#L2844) in ionic.js and here’s the console.log output:

```
tapClick touchend A (66,270)
tapClick mouseup A (66,270) 

```

So what happens it that our expand action immediately collapses again and removes all the recently-added elements from the DOM.

If I add the _data-tap-disabled=“true”_ attribute to the HTML tag, then the behavior disappears (but the 300ms delay is reintroduced).

---

<div class="post-metadata">

**Author:** ![jfrumar](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jfrumar](https://forum.ionicframework.com/u/jfrumar)\
**Post date:** [May 7, 2015, 11:34pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/2 "2015-05-07T23:34:13Z")

</div>

As a workaround, I am recording the x & y coords of the tap event, and if the subsequent tap event matches both, then I ignore it.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [May 8, 2015, 4:32pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/3 "2015-05-08T16:32:29Z")

</div>

Ionic’s tap system shouldn’t be fire click events twice, is there anyway you could replicate this is a codepen?

---

<div class="post-metadata">

**Author:** ![OfirCohen](https://avatars.discourse-cdn.com/v4/letter/o/a5b964/32.png) [@OfirCohen](https://forum.ionicframework.com/u/OfirCohen)\
**Post date:** [June 28, 2015, 12:50pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/4 "2015-06-28T12:50:01Z")

</div>

I have the same exact issue (touchend + mouseup ) for a single ng-click.  
It happens only when the button is inside ‘ion-nav-buttons’ tag, when we put the button inside the ‘ion-content’ tag it doesn’t happen.  
See codepen which is very similar to the actual code - the bug does not reproduce on the codepen:  
[http://codepen.io/OfirCohen/pen/RPxZYy](http://codepen.io/OfirCohen/pen/RPxZYy)

---

<div class="post-metadata">

**Author:** ![OfirCohen](https://avatars.discourse-cdn.com/v4/letter/o/a5b964/32.png) [@OfirCohen](https://forum.ionicframework.com/u/OfirCohen)\
**Post date:** [July 1, 2015, 12:50pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/5 "2015-07-01T12:50:01Z")

</div>

I have created a sample app to reproduce this and it happens both in native apk and in “ionic View” - can someone from ionic team look at this? i can share the app via “ionic view” and share the code. (“ionic view” app ID 282a253d)  
It is reproduce on Android 4.4.2 and 5.x.x (also sometimes on iOS 8.3)

Thanks

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 1, 2015, 4:02pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/6 "2015-07-01T16:02:18Z")

</div>

Can you provide some code to look at. Can’t really see if there is an issue without a codepen to work off of

---

<div class="post-metadata">

**Author:** ![OfirCohen](https://avatars.discourse-cdn.com/v4/letter/o/a5b964/32.png) [@OfirCohen](https://forum.ionicframework.com/u/OfirCohen)\
**Post date:** [July 1, 2015, 9:16pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/7 "2015-07-01T21:16:24Z")

</div>

I created a codepen here: [http://codepen.io/OfirCohen/pen/RPxZYy](http://codepen.io/OfirCohen/pen/RPxZYy)  
But it is not reproduce on PC browser only on real device. So I copied the code to a sample app and uploaded it to ionicview (ID 282a253d) where you can see it happens (is the app ID what needed to share the app in ionicview or should I send it to a specific email?). How can I share the sample app code?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 2, 2015, 4:34pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/8 "2015-07-02T16:34:40Z")

</div>

the codepen is coming up 404.

A codepen will be fine, as it should be a minimal example that reproduces the error.  
Plus, we can [create ionic projects with codepen](http://blog.ionic.io/live-reload-all-things-ionic-cli/) so its very easy to transfer it to a device.

---

<div class="post-metadata">

**Author:** ![OfirCohen](https://avatars.discourse-cdn.com/v4/letter/o/a5b964/32.png) [@OfirCohen](https://forum.ionicframework.com/u/OfirCohen)\
**Post date:** [July 5, 2015, 6:52am UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/9 "2015-07-05T06:52:22Z")

</div>

Sorry for that, for some reason the codepen was private. Here is a public one: [http://codepen.io/OfirCohen/pen/ZGxYVg](http://codepen.io/OfirCohen/pen/ZGxYVg)

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 13, 2015, 6:51pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/10 "2015-07-13T18:51:59Z")

</div>

Not sure what I should be looking for. Everything seems to work fine

---

<div class="post-metadata">

**Author:** ![OfirCohen](https://avatars.discourse-cdn.com/v4/letter/o/a5b964/32.png) [@OfirCohen](https://forum.ionicframework.com/u/OfirCohen)\
**Post date:** [July 14, 2015, 10:51am UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/11 "2015-07-14T10:51:41Z")

</div>

As I wrote at the beginning of the post it is not reproduce on PC but on real device only (Android- always, iPhone-sometimes) please convert the code pen to ‘ionic view’ app, press on the filter button on the header and you will see the event is fired twice. Thanks.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 14, 2015, 5:34pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/12 "2015-07-14T17:34:24Z")

</div>

Right, I’m not seeing that on my android device with the latest release. Is there any particular version of android you’re seeing this?

---

<div class="post-metadata">

**Author:** ![OfirCohen](https://avatars.discourse-cdn.com/v4/letter/o/a5b964/32.png) [@OfirCohen](https://forum.ionicframework.com/u/OfirCohen)\
**Post date:** [July 15, 2015, 8:49am UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/13 "2015-07-15T08:49:34Z")

</div>

We see it on Android 4.4.2 and 5.x.x and iPhone 6 (8.4)

---

<div class="post-metadata">

**Author:** ![Slavrix](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/slavrix/32/76190_2.png) [@Slavrix](https://forum.ionicframework.com/u/Slavrix)\
**Post date:** [July 29, 2015, 9:37am UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/14 "2015-07-29T09:37:01Z")

</div>

Hmm, I’ve got a similar issue to this also.  
I’ve got a button that fires twice when its touched on device, once when clicked through ionic serve.  
The function that is called takes up a bit of time to complete (it has a forEach in it and iterates through setting visibility for markers on a map).  
If I comment out the forEach, and have just a $log there to show its been pressed, it only fires once.  
It seems to only fire twice if the function called is slow to process.  
I’m seeing it on android 4.4.2 on a Samsung s5  
Tested on 5.0.0 on Nexus 5 and the issue isn’t there.

---

<div class="post-metadata">

**Author:** ![Shredmer](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Shredmer](https://forum.ionicframework.com/u/Shredmer)\
**Post date:** [September 8, 2015, 8:49pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/15 "2015-09-08T20:49:07Z")

</div>

I too am having this issue as mentioned:

> **[Ionic.bundle.js causes ng-click event to fire multiple times](http://forum.ionicframework.com/t/all-ng-click-events-fire-twice/32008)**
>
> For anyone looking for a fix, this issue has been posted: https://github.com/driftyco/ionic/issues/4345 In my ionic app, all of my ng-click events are firing twice. I have simplified the code to the following: play.ionic.io/app/2fc7300bf4a6 NOTE:...

AND

> <https://stackoverflow.com/questions/32466241/ionic-angularjs-all-ng-click-events-are-firing-twice>

The error is not produced in the browser and is clearly not related to the code itself:

[http://play.ionic.io/app/2fc7300bf4a6](http://play.ionic.io/app/2fc7300bf4a6)

However testing in the emulator or on a real device this occurs.

I have Ionic version 1.6.4 installed.

---

<div class="post-metadata">

**Author:** ![jfrumar](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@jfrumar](https://forum.ionicframework.com/u/jfrumar)\
**Post date:** [November 6, 2015, 9:25pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/16 "2015-11-06T21:25:27Z")

</div>

Update: The workaround of recording the coords and ignoring subsequent events is failing for us now on iOS 9.

`Nov-06-2015-1:16:37PM::gaDiscussionPost >> – "Received tap event to toggle replies at (x/y): 182/205"`  
`173Nov-06-2015-1:16:37PM::gaDiscussionPost >> – "Received tap event to toggle replies at (x/y): 183/205"`

It looks like the X coord is changing by 1. I can update our workaround, but if anyone targets the root issue then that would be better to avoid future issues.

---

<div class="post-metadata">

**Author:** ![jfbloom22](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jfbloom22](https://forum.ionicframework.com/u/jfbloom22)\
**Post date:** [December 16, 2015, 3:37pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/17 "2015-12-16T15:37:40Z")

</div>

I am having a similar issue on IE11. with Ionic 1.1.1 and 1.2. When I put a breakpoint on the goBack function, I see that it consistently fires twice for some reason. IE10 works fine.  
HTML  
`<ion-nav-buttons side="left"> <button nav-clear ng-click="goBack()" class="button icon-left ion-chevron-left button-clear"> Back </button> </ion-nav-buttons> <ion-nav-buttons side="secondary"> </ion-nav-buttons>`

```
 Javascript

```

`$scope.goBack = function () { //if history go back one, else go back to main if ($ionicHistory.backTitle()) { $ionicHistory.goBack(-1); } else { $state.go('app.main'); } };`

---

<div class="post-metadata">

**Author:** ![LouisR](https://avatars.discourse-cdn.com/v4/letter/l/9de053/32.png) [@LouisR](https://forum.ionicframework.com/u/LouisR)\
**Post date:** [January 10, 2016, 8:35pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/18 "2016-01-10T20:35:35Z")

</div>

My click events fire twice too on iOS simulator and devices. Did someone found a solution ? (ionic 1.2.1)

---

<div class="post-metadata">

**Author:** ![jasoncartermartin](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jasoncartermartin/32/68551_2.png) [@jasoncartermartin](https://forum.ionicframework.com/u/jasoncartermartin)\
**Post date:** [January 12, 2016, 7:03am UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/19 "2016-01-12T07:03:45Z")

</div>

I’m also having my ng-click events firing twice! Can’t figure out how to fix it

---

<div class="post-metadata">

**Author:** ![persyval](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/persyval/32/8762_2.png) [@persyval](https://forum.ionicframework.com/u/persyval)\
**Post date:** [January 20, 2016, 12:19pm UTC](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585/20 "2016-01-20T12:19:34Z")

</div>

I am seeing the same issue.  
I see buttons fired twice if the underlying method is taking a long time.

Strange thing is, it seems to be tied to the physical screen.  
I have a goBack button that when clicked navigates to another view.  
That view has a goBack button on exactly the same spot, and that button gets clicked after a slight delay.  
So it seems the physical tap is registered twice, and the first time it calls a function on my first view and then the function on my second view.

Adding data-tap-disabled=“true” to the button helps.  
But now I need to add it to all my buttons it seems.

[Next page](https://forum.ionicframework.com/t/ng-click-fires-twice-in-response-to-a-single-tap/22585.md?page=2)
