Here is a situation that I am dealing with:
controller.ts
methodA(): void {
myServive.someMethod()
.then( () => console.log("then") )
.catch( e => {
console.log("catch");
});
}
service.ts
someMethod(): ng:IPromise<void> {
const deferred = this.$q.defer<void>();
return this.OtherService.otherMethod()
.catch ( e => {
deferred.reject(reason);
}
}
otherservice.ts
otherMethod(): ng.IPromise<any> {
return this.HttpService.get(url);
}
Test:
- The otherMethod (otherService.ts) is encountering an error from the HttpService.
- The catch in someMethod (service.ts) is being executed.
Why, in the controller.ts, is the then block being executed?