Error: Can't resolve all parameters for ProductsEffects: (?, ?)

Error: Can't resolve all parameters for ProductsEffects: (?, ?)

我是 运行 Angular 9,使用 @ngrx/store v9,使用 SSR,但我只是 运行 npm start 在开发中,所以SSR并不是一个真正的因素。

我刚刚添加了 NGRX 商店并为一些产品制作了我的动作、减速器和效果。在 运行 之后,我现在得到错误:Error: Can't resolve all parameters for ProductsEffects: (?, ?).

ProductsEffectsclass构造函数如下:

constructor(private actions$: Actions<ProductsActions>,
            private appService: AppService) {
}

AppService class 被标记为 @Injectable({providedIn: 'root'})actions$ 应该从 NGRX Store 注入。

这是来自 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 class