2016-10-16 9 views
0

ang1のHTTP要求の完了を検出する可能性はありますか?ang1のHTTP要求の完了を検出する方法

製品の工場:

app 
    .factory('productFactory', ['$http','config', 
    function($http,config) { 
     var url = config.domainBase +':'+config.domainPort +config.additionalPath+'/Product/All' 
     return { 
     getAll: function() { 
      return $http.get(url); 
     } 
     }; 
    } 
    ]); 

プロダクトコントローラー:

var req = productFactory.getAllServers(); 
      req.success(function(response) { 
//.... 
}). 
error(function(error){ 
//error 
}); 

答えて

1

は$ qをインジェクタ

var deferred = $q.defer(); 
 
var params = { 
 
    ... 
 
}; 
 
$http.post('http://www.example.com', JSON.stringify(params)) 
 
    .success(function(object) { 
 
    // On success 
 
    }) 
 
    .error(function(object, status) { 
 
    // On error 
 
    }); 
 
return deferred.promise;

を見てみましょう
関連する問題