그래서 $ q.all을 사용하여 $ 리소스 호출을 배치하는 간단한 예제가 있는데, 제가 알고 싶은 것은 왜 내 업데이트 처리기가 호출되지 않았습니까?
각 약속이 성공적으로 완료된 후에 전화를 걸 것이라고 생각했을까요?
결과 핸들러 만 호출됩니다. 내가 도대체 뭘 잘못하고있는 겁니까?
var promises = [];
angular.forEach($scope.mappedData, function(item) {
var resource = new Resource(item);
promises.push(resource.$save());
});
$q.all(promises).then(
function(result) {
console.log('result', result);
},
function(error) {
console.log('error', error);
},
function(notify) {
console.log('notify', notify);
}
);
그래서 실제로 각 약속이 완료된 후 '알림 서비스'메소드를 호출 지연된 객체를 생성하지 않는 이유는 무엇입니까? 그것이 내가 생각한 것입니다. 그러나 나는 생각하지 않습니다 ... –
아니요, $ q.all은 모든 약속이 끝날 때까지 기다립니다. –