无法解析功能模块中的HttpInterceptors [英] Not able to resolve HttpInterceptors in feature module
问题描述
当尝试在功能加载的模块中获取注册的HttpInterceptor时( @Inject(HTTP_INTERCEPTORS)拦截器:HttpInterceptor [],
),我只是得到一个注册了一个拦截器的数组: HttpXsrfInterceptor .
When trying to get the registered HttpInterceptors in a feature loaded module (@Inject(HTTP_INTERCEPTORS) interceptors: HttpInterceptor[],
) I just get an array with one interceptor registered: HttpXsrfInterceptor.
在AppModule中执行相同操作时,我将获得所有可用的拦截器.是什么导致我的问题?我想通过某些模块设置一些拦截器属性.
When doing the same in the AppModule I get all the interceptors available. What is causing my issue? I'd like to set some interceptor properties by some modules.
推荐答案
必须在导入HttpClientModule的同一模块中提供拦截器.它可以解释为什么它只能在您的AppModule中使用.
Interceptors must be provided into the same Module which import HttpClientModule. It might explain why it only works in your AppModule.
这篇关于无法解析功能模块中的HttpInterceptors的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!