Surjeet Bhadauriya Surjeet Bhadauriya - 4 months ago 24
AngularJS Question

In which sequence or manner multiple functions is called if i call them inside ng-click?

I have this code.

<button type="button" ng-click="func1(); func2(); func3()">Click</button>


I want to know that how func1,func2, and func3 will be called? Is it according to their sequence or parallely?

Answer

According to sequence

<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

<button type="button" ng-click="func1(); func2(); func3()">Click</button>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {

    $scope.func1= function(){
alert("1");
};
    $scope.func2= function(){
alert("2");
};
    $scope.func3= function(){
alert("3");
};
});
</script>

</body>
</html>

http://codepen.io/nagasai/pen/vKWRwr