0
私のhandlerError関数内にtoastrを持つ方法を理解しようとするのに問題があります。私はそれを実行すると、私は受信エラーがToastrをhttp catch機能の中に追加するには?
未定義の
'エラー' はここでは
post(url, data): Observable<any> { this.toastrService.error('hey'); // <-- This works return this.http.post(CONSTANT.API_URL + url, data, { headers: this.createAuthorizationHeader() }). map((res:Response) => { return this.toCamel(res.json()) }). catch(this.handlerError); }
Toastrのように呼ばれている私のコード
private handlerError(error: any) { var errorMessage = 'Server error'; this.toastrService.error(errorMessage); <-- This doesn't work return Observable.throw(errorMessage); }
です注入中
constructor(private http: Http, private toastrService: ToastrService) {}
を印刷します。 Thanx – Demodave
私は追加の説明を追加しました –