shredMER
shredMER

Reputation: 227

Ionic AngularJS All ng-click events are firing twice?

My ng-click events are firing twice in my Ionic app and I have not been able to figure out how to fix this. To test this error, I have compressed my code to the following (the error is still occurring in the iOS emulator and on the iOS device, however not in the browser nor on android):

Running version (rendered by browser, error is not produced): play.ionic.io/app/2fc7300bf4a6

JS

(function() {

var app = angular.module('nh-launch', ['ionic']);

app.controller('testCtrl', function($scope) {
    $scope.testClick = function () {
         alert("hello");
    };
});

}());

HTML

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title>NoHarm Safety Application</title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/ngCordova/dist/ng-cordova.js"></script>
    <script src="lib/angular-resource/angular-resource.js"></script>
    <script src="lib/angular-random-string/src/angular-random-string.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>

  </head>
  <body ng-app="nh-launch">

   <ion-pane>
    <ion-content>

        <div ng-controller="testCtrl">
            <button ng-click="testClick()" class="button button-block button-calm">Test Click</button>
        </div>

    </ion-content>  
    </ion-pane>

  </body>
</html>

Help is greatly appreciated!

Upvotes: 2

Views: 2909

Answers (1)

shredMER
shredMER

Reputation: 227

This is a current bug with ionic. It is due to the alert() and $window.alert() functions. I have posted the issue here: https://github.com/driftyco/ionic/issues/4345#issuecomment-139026496

Upvotes: 1

Related Questions