admin管理员组文章数量:1406926
I just upgraded my Angular v4.2.5
app to Angular v4.3.6
primarily to use Interceptors
. It is quite an awesome feature and provides a clean way to intercept HTTP calls.
However, it seems I cannot scope interceptors at modules level. For example, I have an AppModule
, and two more modules AModule
and BModule
. Both AModule
and BModule
are getting included in AppModule
.
Now, is there a way in Angular 4 where I can scope interceptors at module level such that an interceptor I use for HTTP requests in AModule
shouldn't be used with HTTP requests in BModule
. Presently, interceptors are getting shared across all HTTP calls which was not I expected. I know providers
from all modules get merged into the parent module, but is there any way to restrict such thing?
Any help is highly appreciated.
I just upgraded my Angular v4.2.5
app to Angular v4.3.6
primarily to use Interceptors
. It is quite an awesome feature and provides a clean way to intercept HTTP calls.
However, it seems I cannot scope interceptors at modules level. For example, I have an AppModule
, and two more modules AModule
and BModule
. Both AModule
and BModule
are getting included in AppModule
.
Now, is there a way in Angular 4 where I can scope interceptors at module level such that an interceptor I use for HTTP requests in AModule
shouldn't be used with HTTP requests in BModule
. Presently, interceptors are getting shared across all HTTP calls which was not I expected. I know providers
from all modules get merged into the parent module, but is there any way to restrict such thing?
Any help is highly appreciated.
Share Improve this question asked Aug 28, 2017 at 15:04 Imran LatifImran Latif 1,0239 silver badges23 bronze badges 1-
What if you have two services that extend Http and add them to the corresponding module's
providers
;AService
toAModule
andBService
toBModule
, Doesn't the service only be applied to coresponding module? – Prav Commented Aug 28, 2017 at 15:13
1 Answer
Reset to default 6Add a header or flag to the request from the different services? And then use this to delineate where it is from.
本文标签: javascriptAngular HTTP Interceptors at Module LevelStack Overflow
版权声明:本文标题:javascript - Angular HTTP Interceptors at Module Level - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744987718a2636191.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论