Ng-click events fire twice everytime

i downloaded the beta and made a simple app that just navigates between pages. Every ng-click fires twice.

code:var app = angular.module(‘app’, [‘ionic’]);
app.config([’$stateProvider’, ‘$urlRouterProvider’, function ($stateProvider, $urlRouterProvider) {
$stateProvider.
state(‘profile’,
{
url: “/profile”,
templateUrl: “profile.html”,
controller: “ProCtrl”
}).
state(‘login’, {
url: “/login”,
templateUrl: “login.html”,
controller: “LoginCtrl”
}).state(‘home’, {
url: “/home”,
templateUrl: “home.html”,
controller: “HomeCtrl”
});
$urlRouterProvider.otherwise(’/login’);
}]);
app.controller(‘LoginCtrl’, [’$scope’, ‘$location’, function ($scope, $location) {
alert(‘login’);
$scope.go = function () {
$location.path(’/home’);
}
}]);
app.controller(‘ProCtrl’, [’$scope’, ‘$location’, function ($scope, $location) {
alert(“profile”);
}]);
app.controller(‘HomeCtrl’, [’$scope’, ‘$location’, function ($scope, $location) {
alert(“home”);
$scope.go = function () {
$location.path(’/profile’);
}
}]);

Can you setup an example on codepen? Its hard to know how it should behave without the html and javascript.

Which platform and which version are you on? Chrome, Android, iOS?

im testing on the newest version of chrome. ive discovered the issue it happens when i use requirejs to either load ionic.bundle or individually load the necessary files.
note when i load angular alone with requirejs in the same manner the double ng-clicks dont happen.

open this in the latest version of chrome. http://codepen.io/anon/pen/Ffdtj/

we’re having the exact same problem

Yea is here a solution for? because i got the same problem.

I forked your example @superc and did not use require to load things. It only triggers the methods once in this case. I don’t use require, so I’m not much help in knowing where the source problem.

Hey, we found a quick solution:

Do not use ionic bundle.
Get ionic and ionic-angular from the download page.
Load the ionic lib in your index.html head area before you are loading your requirejs configuration.

In your requirejs configuration you can add now angularjs and the ionic-angular lib.

now you can do something like:

define([
  'angular',
  'angular-ionic'
], function (angular) {
  angular.module('yourApp', ['ionic']);
});

Greets, bengtler

See here :

I have the same problem - I have a simple Controller and page with a click event and a console.log in it and it always fires twice… will try to debug it.

Codepen would be great :wink:

I think it is something to do with using AppBuilder and Cordova - I can see in this CodePen http://codepen.io/anon/pen/JrpuB when I change it to use the .13 beta it no longer fires twice. I also have noticed that it only does this during development and I know AppBuilder does some “clever” stuff with Cordova to get the latest version and also mock up a simulator… so it’s probably not a huge issue.

Ah you are using beta 1… there was a generally bug in the click handler.

It is recommended to use the latest beta.

No, sorry for the confusion, I grabbed that CodePen and edited it to use the .13 CDN and it stopped doing the 2 clicks. I am using .13 in my Dev Environment (I was just pointing out that it is therefore probably an AppBuilder oddity).

cheers

Hey @rodneyjoyce

Finally someone who develops with AppBuilder :smiley:

I think its an AppBuilder problem coze i have the same problem(sometimes it does up to 3 clicks at same time).
But i think its only in Simulator on Phone i don’t facing this problem. except my array.slice() problem.

Agree.

Yes, I am suprised there are not more. After using PhoneGap and PhoneGap Build, Steroids etc. I am amazed at the productivity and tooling in AppBuilder (and it’s free for 2 projects). Have you tried the Telerik Feedback plugin? Very impressive…

You should really create a different topic or go private to discuss appbuilder further :wink: I would love to know more about it thougn, does it work well with ionic and stuff like that? :slight_smile: Open a new topic for this and invite me to join please :smiley: