//Http services
// =============================================================================
quotePlansController.factory('httpServices',['$http', function(http){
return {
//post: function(url,para,config){
post: function(url,para){
//---->response here is just response.data
var httpPromise = http.post(url,para).success(function(response) {
console.log('HttpServices post fliter~~');
//TODO
});
// response here is original,include(data,status,headers),passed by last Promise.
httpPromise.success = function(fn)
{
httpPromise.then(function(response) {
//console.log('our call back here~!post');
//fn(response.data, response.status, response.headers, config);
fn(response.data, response.status, response.headers);
});
return httpPromise;
};
return httpPromise;
},
//get: function(url,config){
get: function(url){
//---->response here is just response.data
var httpPromise = http.get(url).success(function(response) {
console.log('HttpServices get fliter~~');
//TODO
});
//here response is original,include(data,status,headers),passed by last Promise.
httpPromise.success = function(fn)
{
httpPromise.then(function(response) {
//console.log('our call back here~!get');
//fn(response.data, response.status, response.headers, config);
fn(response.data, response.status, response.headers);
});
return httpPromise;
};
return httpPromise;
}
}
}]);
// =============================================================================
quotePlansController.factory('httpServices',['$http', function(http){
return {
//post: function(url,para,config){
post: function(url,para){
//---->response here is just response.data
var httpPromise = http.post(url,para).success(function(response) {
console.log('HttpServices post fliter~~');
//TODO
});
// response here is original,include(data,status,headers),passed by last Promise.
httpPromise.success = function(fn)
{
httpPromise.then(function(response) {
//console.log('our call back here~!post');
//fn(response.data, response.status, response.headers, config);
fn(response.data, response.status, response.headers);
});
return httpPromise;
};
return httpPromise;
},
//get: function(url,config){
get: function(url){
//---->response here is just response.data
var httpPromise = http.get(url).success(function(response) {
console.log('HttpServices get fliter~~');
//TODO
});
//here response is original,include(data,status,headers),passed by last Promise.
httpPromise.success = function(fn)
{
httpPromise.then(function(response) {
//console.log('our call back here~!get');
//fn(response.data, response.status, response.headers, config);
fn(response.data, response.status, response.headers);
});
return httpPromise;
};
return httpPromise;
}
}
}]);