无法解析功能模块中的HttpInterceptors [英] Not able to resolve HttpInterceptors in feature module

查看:69
本文介绍了无法解析功能模块中的HttpInterceptors的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试在功能加载的模块中获取注册的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆