I am trying to do something very similar to the $http service. From my understanding $http return a promise object.
When using it the syntax is :
$http(.
The nice thing with open-source is that you can read the source. Here's how the $http service does it:
promise.success = function(fn) {
promise.then(function(response) {
fn(response.data, response.status, response.headers, config);
});
return promise;
};
promise.error = function(fn) {
promise.then(null, function(response) {
fn(response.data, response.status, response.headers, config);
});
return promise;
};