当使用 ng-click
调用多个方法时,如
ng-click="select(); highlight()"
它们是否按顺序执行,即首先 select()
然后是 highlight()
?
最佳答案
是它们按照编写/调用的方式执行。
参见 Fiddle .
这是来自 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");
}
}
关于javascript - Ng-click - 调用多个方法时顺序是否重要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30072153/