Angular ng-submit called twice

Check you didn't declare your controller twice: one in the HTML, as I can see above, and another when configuring your routes. If it's the case, the controller is instanciated twice, so the listener is invoked twice


One reason happend to me, I'm not sure if this will happen to any other :)

In my controller I had:

$scope.submit = function() { someThingHere };

In the view

<form ng-submit="submit()">
</form>

This way that form has been submitted "mysteriously" two times, to solve that I had to rename $scope.submit to something else.


Another reason for this occurring (which just happened to me):

I had the following:

<form ng-submit="myCtrl.search()">
   <button type="submit">Search</button>
   <button type="submit" class="mobile-only" ng-click="myCtrl.search()">Go</button>
</form>

I had another button inside the form that was bound to the same function as the ng-submit on its ng-click which was causing the method to be called twice.