JH-Sen-Ren
JH-Sen-Ren

Reputation: 279

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

I'm running Angular 9, with @ngrx/store v9, and with SSR, but I'm just running npm start in development, so SSR isn't really a factor.

I just added NGRX Store and made my actions, reducers and effects for some products. Upon running this, I now get the error: Error: Can't resolve all parameters for ProductsEffects: (?, ?).

The ProductsEffects class constructor is as follows:

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

The AppService class is marked as @Injectable({providedIn: 'root'}), and actions$ should be injected from NGRX Store.

Here's the imports section from 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()
    ],

Here's the relevant section from package.json:

"@ngrx/effects": "^9.0.0",
"@ngrx/entity": "^9.0.0",
"@ngrx/router-store": "^9.0.0",
"@ngrx/store": "^9.0.0",

Any help would be much appreciated!

Upvotes: 1

Views: 1253

Answers (1)

JH-Sen-Ren
JH-Sen-Ren

Reputation: 279

The issue was I had forgotton to decorate the ProductsEffects class with @Injectable().

Upvotes: 7

Related Questions