Ng-click - 调用多个方法时顺序是否重要?
Ng-click - does the order matter when calling multiple methods?
使用 ng-click
调用多个方法时,如
ng-click="select(); highlight()"
它们是否按顺序执行,即首先 select()
然后 highlight()
?
是的它们的执行方式是written/called。
参见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");
}
}
使用 ng-click
调用多个方法时,如
ng-click="select(); highlight()"
它们是否按顺序执行,即首先 select()
然后 highlight()
?
是的它们的执行方式是written/called。
参见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");
}
}