如何处理使用ngrx时遇到的错误消息: NullInjectorError R3InjectorError(AppModule)[StoreFeatureModule]

如何处理使用ngrx时遇到的错误消息: NullInjectorError R3InjectorError(AppModule)[StoreFeatureModule]错误消息:


main.ts:12 NullInjectorError: R3InjectorError(AppModule)[StoreFeatureModule -> ReducerManager -> ReducerManager -> ReducerManager]:

NullInjectorError: No provider for ReducerManager!

at NullInjector.get (http://localhost:4200/vendor.js:8310:27)

at R3Injector.get (http://localhost:4200/vendor.js:22317:33)

at R3Injector.get (http://localhost:4200/vendor.js:22317:33)

at R3Injector.get (http://localhost:4200/vendor.js:22317:33)

at injectInjectorOnly (http://localhost:4200/vendor.js:8165:33)

at Module.ɵɵinject (http://localhost:4200/vendor.js:8175:57)

at Object.StoreFeatureModule_Factory [as factory] (http://localhost:4200/vendor.js:64143:380)

at R3Injector.hydrate (http://localhost:4200/vendor.js:22555:63)

at R3Injector.get (http://localhost:4200/vendor.js:22305:33)

at http://localhost:4200/vendor.js:22351:25


根据这篇文章的提示:

https://www.manongdao.com/article-974354.html


StoreModule.forRoot should only be called once in the root of your project NgModule. If you wan’t to register a feature, use StoreModule.forFeature. Using forRoot registers the global providers needed for Store.


在app module里添加一行代码即可解决:

如何处理使用ngrx时遇到的错误消息: NullInjectorError R3InjectorError(AppModule)[StoreFeatureModule]

上一篇:一起谈.NET技术,了解 C# 4 中的 Dynamic 关键字


下一篇:文件(图片)强制下载