I have a handleError () method, as in the documentation https://angular.io/docs/ts/latest/guide/server-communication.html#!#error-handling
private handleError(error: any) {
console.error(error);
console.log(this.loginService);
return Observable.throw(error);
}
My problem is that this.loginService is undefined , although it was correctly injected into my class. It is already used in other methods, but does not seem to be available in handleError .
Can a problem call the http-catch method a problem? If so, how can I get around this? I need to follow some logic when handling the error.
This is an example of how I set the handleError method as a callback (just like the documentation)
this.http.get(url,
ApiRequest.ACCEPT_JSON)
.map(ApiHelper.extractData)
.catch(this.handleError);