我必须在检索数据集合后进行顺序AJAX调用。我遇到的问题解决了嵌套的承诺。angular.forEach解析嵌套承诺
基本上,我需要扩展我的第一个集合中返回的每个对象,其属性为ActionItems
,并用承诺设置它的值,然后解析集合中的每个承诺。
任何帮助将不胜感激。
厂
$http.get(urlBase + 'Project?$expand=Plant,CreatedBy,ModifiedBy,Plant/Contacts').then(function(success){
var contents = {};
contents = success.data.d.results;
return contents;
})
.then(function(contents){
var contentPromises = [];
angular.forEach(contents, function(content) {
contentPromises.push(
$http.get(urlBase + "ActionItems?$filter=ProjectId eq " + content.Id).then(function(success){
content['ActionItems'] = success.data.d.results;
})
);
});
return $q.all(contentPromises).then(function() {
return contents;
});
});
电流输出不确定
什么不处理您的代码? – devqon
它返回undefined – ExceptionLimeCat