是否有可能在angular1?
中检测到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
});
答案 0 :(得分: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;