Error: [$rootScope:inprog] $digest already in progress
基本上我试图在for循环中同时运行两个promise对象:
angular.module('core').controller('HomeController', function($q, $http, $scope) {
for (var i = 0; i < window.config.Environments.length; i++) {
for (var j = 1; j < window.config.Clusters[i] + 1; j++) {
//Promise Object 1
promiseObj.physical[window.config.Environments[i] + "#Cluster" + j] = $http.get('url/search?idc=' + window.config.Environments[i] + '&type=Physical&cluster=' + j).success(function(i,j) {
return function(data) {
$scope.servers = data; // get data from json
angular.forEach($scope.servers, function(item) {
//some code
});
}
}(i,j));
//Promise Object 1
promiseObj.virtual[window.config.Environments[i] + "#Cluster" + j] = $http.get('url/search?idc=' + window.config.Environments[i] + '&type=Virtual&cluster=' + j).success(function(i,j) {
return function(data) {
angular.forEach($scope.virtualservers, function(item) {
//some code
});
}
}(i,j));
}
}
});
提前谢谢