Angular6:handleError 无法读取注入的服务?

Angular6: handleError can't read services injected?

我似乎无法读取 handleError 函数中注入的服务

constructor(private http: HttpClient, public _translate: TranslateService) { }        
login(user: User): Observable<User> {               
      console.log( this._translate); // I CAN READ THE SERVICE INJECTED    
      return this.http.post<User>("http://...../login",  params, httpOptions)
            .pipe(catchError(this.handleError));                  
}

private handleError(error: HttpErrorResponse) {    
      console.log( this._translate); I CAN'T READ THE SERVICE INJECTED                           
      return throwError(error.error);                     
};

您在 .pipe(catchError(this.handleError));

中使用未绑定函数作为参数正在失去 this 上下文

应该是

  .pipe(catchError(this.handleError.bind(this)));

或使用箭头函数

       .pipe(catchError((err)=>this.handleError(err)));