$http({
'url':'/jtkj/yjmc',
'method':'POST',
})
.success(function(res) {
$scope.yjdh = res;
console.log(res);
var navUrl = ['/genSit','/news','/set','/manage','/cooperate','/admNet','/eplNet','/stuMan'];
//传值,循环遍历出数据
$scope.xlcd = [];
for(var i=0;i<res.length;i++){
$scope.yjid = res[i].yjid;
console.log(res[i].yjid);
ejnameGet($scope.yjid);
$http({
url:'/jtkj/ejmc',
method:'POST',
data:{yjid:$scope.yjid}
}).success(function(xlcd1){
//$scope.xlcd = xlcd1;
console.log(xlcd1);
xlcd.push(xlcd1);
})
}
//console.log($scope.xlcd);
$scope.xlcd = xlcd;
console.log($scope.xlcd);
世界只因有你2017-06-12 09:28:54
Push whichever asynchronous request is completed. It’s normal for chaos to occur; don’t use push, subscript directly through i, and just pay attention to the processing of the i value (IIFE can be used)
黄舟2017-06-12 09:28:54
One idea is to construct a storage structure such as an array, and when the asynchronous function i is executed, put the data back into array[i].
大家讲道理2017-06-12 09:28:54
You can use the promise.all method to put the request into an array, so that the order will not be messed up.