angularjsに$ q.allを実装しましたが、コードを機能させることができません。これが私のコードです:
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.promise);
        }
        return $q.all(promises);
    }
そして、これがサービスを呼び出す私のコントローラーです:
uploadService.uploadQuestion(questions).then(function(datas){
   //the datas can not be retrieved although the server has responded    
}, 
function(errors){ 
   //errors can not be retrieved also
})
私のサービスで$ q.allの設定に問題があると思います。
                  @ themyth92私の解決策を試しましたか?
                
                
                  
                    —
                    Ilan Frumer 2014年
                    
                  
                
              
                  私は試しましたが、どちらの方法も私のケースで機能します。しかし、正解は@Llan Frumerにします。本当にありがとうございました。
                
                
                  
                    —
                    themyth92 2014年
                    
                  
                
              
                  なぜ既存の約束を約束するのですか?$ httpはすでにpromiseを返します。$ q.deferの使用は不必要です。
                
                
                  
                    —
                    ピートアルヴィン
                    
                  
                
              
                  それは:) ではあり
                
                  
                    —
                    クリストフ・ルシー
                    
                  
                
              deferredませんdeffered
                
then(datas)か?pushこれだけを試してください:promises.push(deffered);