If I have a service that returns an $http promise, then how can I attach into the errorCallback?
MyService:
self.getData = () => {
let promise = $http.get('/api/getData').then(x => {
return x;
}, x => {
//This is reached on server-side error
return x;
});
return promise;
};
Directive controller:
MyService.getData().then(x => {
//This is always executed regardless of whateher the success or error functions are executed in the promise
}, x => {
//This is not executed
});
The errorCallback is executed, but then when trying to attach to that promise in my directive, it always runs the success function.