错误:无法解析 ProductsEffects 的所有参数:(?, ?)

JH-*_*Ren 1 ngrx-effects angular ngrx-store

我正在运行 Angular 9、@ngrx/storev9 和 SSR,但我只是npm start在开发中运行,所以 SSR 并不是真正的因素。

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

ProductsEffects类构造函数如下:

constructor(private actions$: Actions<ProductsActions>,
            private appService: AppService) {
}
Run Code Online (Sandbox Code Playgroud)

AppService 类标记为@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()
    ],
Run Code Online (Sandbox Code Playgroud)

以下是相关部分package.json:

"@ngrx/effects": "^9.0.0",
"@ngrx/entity": "^9.0.0",
"@ngrx/router-store": "^9.0.0",
"@ngrx/store": "^9.0.0",
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激!

JH-*_*Ren 7

问题是我忘记用 来装饰ProductsEffects班级@Injectable()。