が、それはこのようなものです:angular2 httpインターセプターと注入SlimLoadingBarServiceは機能しませんか?私は、HTTP intercpetorを書く
{
provide: HttpInterceptorService,
useFactory: (backend: XHRBackend, defaultOptions: RequestOptions) => {
return new HttpInterceptorService(CONFIG, backend,
defaultOptions, new SlimLoadingBarService);
},
deps: [XHRBackend, RequestOptions]
}
は今、このHTTPインターセプタは労働者である、しかし、SlimLoadingBarService
は動作しませdoew:
import { Injectable, Inject } from '@angular/core';
import { SlimLoadingBarService } from 'ng2-slim-loading-bar';
// ... other imports in here
@Injectable()
export class HttpInterceptorService extends Http {
private apiEndpoint: string;
constructor(
@Inject(CONFIG_TOKEN) config: Config,
private backend: ConnectionBackend,
private defaultOptions: RequestOptions,
private slimLoadingBarService: SlimLoadingBarService
) {
super(backend, defaultOptions);
this.apiEndpoint = config.apiEndpoint;
}
get(url: string, options?: RequestOptionsArgs): Observable<any> {
this.beforeRequest();
return super.get(this.getFullUrl(url), this.requestOptions(options))
// ...
}
private beforeRequest(): void {
// this is not work
this.slimLoadingBarService.start();
}
// ... other methods
}
私app.moduleは、このように設定を提供します。
私はnew SlimLoadingBarService
の鉛を渡すのが間違っているべきだと感じますが、直接送信SlimLoadingBarService
、同じものが与えられ、今ここに固執して続行する方法がわかりません。
エラーメッセージはありませんが、ローディングバー(SlimLoadingBarService
)は表示されません。
あなたのエラーは何ですか? –
この質問は非常に不明瞭です。助けを求めたり、遭遇したエラーを説明したりするために詳しく説明してください。「動作していません」は問題の説明ではありません。 – n00dl3
@ Karbos538エラーメッセージは表示されませんが、ローディングバーは表示されません。 –