简体   繁体   中英

Ng-click - does the order matter when calling multiple methods?

When calling multiple methods with ng-click , as in

ng-click="select(); highlight()"

do they get executed in order, ie first select() and then highlight() ?

Yes they are executed in the manner they are written/called.

See the Fiddle .

This is from the fiddle:

<div ng-controller="MyCtrl">
  <button ng-click="test(); test1(); test3(); test4();">TEst</button>
</div>

Js:

var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});



function MyCtrl($scope) {
      $scope.test = function(){
       console.log("Hello1");
      }
      $scope.test1 = function(){
       console.log("Hello2");
      }
      $scope.test3 = function(){
       console.log("Hello3");
      }
      $scope.test4 = function(){
       console.log("Hello4");
      }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM