Angular路由复用策略类注入非同目录服务报错求助
Angular自定义RouteReuseStrategy注入跨目录服务触发NullInjectorError
我参照现有方案实现了自定义DetachedAwareRouteReuseStrategy,并在这个策略类中注入了DetachedComponentTrackingService。编译阶段没有任何错误,但应用运行时抛出以下异常:
main.ts:18 Could not load file 'assets/config/config.dev.json': {"name":"NullInjectorError","ngTempTokenPath":["InjectionToken HTTP_INTERCEPTORS","[object Object]","Router","RouteReuseStrategy","DetachedComponentTrackingService","DetachedComponentTrackingService"]}
导致页面完全无法加载。奇怪的是,如果注入和路由复用策略类处于同一目录的服务,整个流程就完全正常。想请教下,怎么才能在自定义RouteReuseStrategy中成功注入应用内任意目录的服务?
内容的提问来源于stack exchange,提问作者Mark
相关产品推荐
相关产品推荐

