我有2个函数bindclub()和displayevent()。我想向bindclub()来运行第一always.I也试图把两者的功能在NG-初始化,但它也不能保证运行bindclub()第一如何确保2个函数中的一个先运行
angular.module('app', []).controller("EventCtrl",EventController);
EventController.$inject = ["$scope", "$http", "$window"];
function EventController($scope, $http, $window) {
$scope.bindclub = function() {
$http({
url: '/Master/bindclub',
method: 'post',
}).then(function (response) {
debugger
$scope.clubidname = response.data;
}, function() { alert("Error in binding club"); });
}
$scope.displayevent = function() {
$http({
url: '/Master/displayevent',
method: 'post',
}).then(function (response) {
alert('Displayed');
}, function() { alert('Error in display event'); });
}
$scope.bindclub();
$scope.displayevent();
}
可能重复的[如何在JavaScript中触发事件?](http://stackoverflow.com/questions/2490825/how-to-trigger-event-in-javascript) – ultrajohn