3 回答
TA贡献1777条经验 获得超10个赞
问题似乎是您要添加deffered.promisewhen deffered本身就是您应该添加的承诺:
尝试更改为promises.push(deffered);,这样就不会将未包装的Promise添加到数组中。
UploadService.uploadQuestion = function(questions){
var promises = [];
for(var i = 0 ; i < questions.length ; i++){
var deffered = $q.defer();
var question = questions[i];
$http({
url : 'upload/question',
method: 'POST',
data : question
}).
success(function(data){
deffered.resolve(data);
}).
error(function(error){
deffered.reject();
});
promises.push(deffered);
}
return $q.all(promises);
}
- 3 回答
- 0 关注
- 633 浏览
添加回答
举报