1
将多个HTTP拦截器添加到Angular应用程序
如何将多个独立的HTTP拦截器添加到Angular 4应用程序? 我试图通过providers使用多个拦截器扩展数组来添加它们。但是只有最后一个被实际执行,才被Interceptor1忽略。 @NgModule({ declarations: [ /* ... */ ], imports: [ /* ... */ HttpModule ], providers: [ { provide: Http, useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions) => new Interceptor1(xhrBackend, requestOptions), deps: [XHRBackend, RequestOptions], }, { provide: Http, useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions) => new Interceptor2(xhrBackend, requestOptions), deps: [XHRBackend, RequestOptions] …