I have this (simplified) service :
@Injectable()
export class DataService {
constructor(protected url: string) { }
private handleError(error: Response) {
console.log(this.url);
return Observable.throw(new AppError(error));
}
getAll() {
return this.http.get(this.url)
.map(response => response.json())
.catch(this.handleError);
}
}
In handleError
function, this.url is undefined. Why ? How can I get the current instance when calling this.handleError
from catch
?
I don't see this being a regular use of this
, the Observable
gets me a lot of TS errors when trying to apply usual JS solutions.
Thanks ahead.