我正在运行Angular 9、@ngrx/store
v9和SSR,但我只是在开发中运行npm start
,所以SSR并不是一个真正的因素。
我刚刚添加了NGRX商店,并为一些产品制作了我的动作、减速器和效果。运行后,我现在得到错误:Error: Can't resolve all parameters for ProductsEffects: (?, ?).
ProductsEffects类构造函数如下所示:
constructor(private actions$: Actions<ProductsActions>,
private appService: AppService) {
}
AppService类被标记为@Injectable({providedIn: 'root'})
,并且actions$
应该从NGRX存储注入。
以下是app.module
的导入部分:
const EFFECTS = [ProductsEffects];
...
imports: [
BrowserModule.withServerTransition({appId: 'my-app'}),
BrowserAnimationsModule,
HttpClientModule,
NgxSpinnerModule,
AgmCoreModule.forRoot({
apiKey: 'redacted'
}),
SharedModule,
routing,
StoreModule.forRoot(reducers, {
metaReducers,
runtimeChecks: {
strictStateImmutability: true,
strictActionImmutability: true
}
}),
EffectsModule.forRoot(EFFECTS),
StoreRouterConnectingModule.forRoot()
],
以下是package.json
:的相关部分
"@ngrx/effects": "^9.0.0",
"@ngrx/entity": "^9.0.0",
"@ngrx/router-store": "^9.0.0",
"@ngrx/store": "^9.0.0",
任何帮助都将不胜感激!
问题是我放弃了用@Injectable()
装饰ProductsEffects
类的想法。