angular ngrx 组件中 constructor 内注入 Store 就会报错

新手上路,请多包涵
import {Store} from '@ngrx/store';
import {StateStoreModule} from '../../state-store/state-store.module';

constructor(private route: ActivatedRoute, private sheetService: sheetService, private store:Store<StateStoreModule>)

image.png

只要不引入 Store 一切正常

 "dependencies": {
    "@angular/animations": "~8.2.3",
    "@angular/common": "~8.2.3",
    "@angular/compiler": "~8.2.3",
    "@angular/core": "~8.2.3",
    "@angular/forms": "~8.2.3",
    "@angular/platform-browser": "~8.2.3",
    "@angular/platform-browser-dynamic": "~8.2.3",
    "@angular/router": "~8.2.3",
    "@ngrx/store": "^9.0.0",
    "@ngrx/store-devtools": "^9.0.0",
    "minireset.css": "0.0.5",
    "ng-zorro-antd": "^8.1.2",
    "rxjs": "~6.4.0",
    "tslib": "^1.10.0",
    "zone.js": "~0.9.1"
  },

这是package.json 配置文件

阅读 2.5k
1 个回答

上述错误是提示你:没有找到Store的提供者,所以发生了NullInjectorError。解决的方法是在当前组件所有在的模块中的imports中,加入Store的提供者.

imports: [
   StoreModule  // 提供Store的模块
]
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题