天天看點

如何處理使用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 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]

繼續閱讀