我有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