5

After updating to Angular 5, I get an error message with my store module. Angular-Redux now has the Version 7.1.0

Unhandled Promise rejection: StaticInjectorError(AppModule)[StoreModule -> NgReduxRouter]: StaticInjectorError(Platform: core)[StoreModule -> NgReduxRouter]: NullInjectorError: No provider for NgReduxRouter! ; Zone: ; Task: Promise.then ; Value: Error: StaticInjectorError(AppModule)[StoreModule -> NgReduxRouter]:
StaticInjectorError(Platform: core)[StoreModule -> NgReduxRouter]: NullInjectorError: No provider for NgReduxRouter! at _NullInjector.get [...]

Here you can see my Store module

import { NgModule, isDevMode } from '@angular/core';

// Angular-redux ecosystem stuff.
// @angular-redux/form and @angular-redux/router are optional
// extensions that sync form and route location state between
// our store and Angular.
import { NgReduxModule, NgRedux, DevToolsExtension } from '@angular-redux/store';
import { NgReduxRouterModule, NgReduxRouter } from '@angular-redux/router';
import { provideReduxForms } from '@angular-redux/form';

// The top-level reducers and epics that make up our app's logic.
import { IAppState, rootReducer, INITIAL_STATE } from './store';

@NgModule({
    declarations: [

    ],
    imports: [NgReduxModule, NgReduxRouterModule],
    exports: [
        ]
    //providers: [RootEpics],
})


export class StoreModule {
    constructor(
        public ngRedux: NgRedux<IAppState>,
        devTools: DevToolsExtension,
        ngReduxRouter: NgReduxRouter,
    ) {
        // Tell Redux about our reducers and epics. If the Redux DevTools
        // chrome extension is available in the browser, tell Redux about
        // it too.
        // devTools nur im Developmentmodus
        var enhancers = isDevMode() ? [devTools.enhancer()] : [];
        ngRedux.configureStore(rootReducer, INITIAL_STATE, [], enhancers); 


        // Enable syncing of Angular router state with our Redux store.
        if (ngReduxRouter) {
            ngReduxRouter.initialize();
        }

        // Enable syncing of Angular form state with our Redux store.
        provideReduxForms(ngRedux);
    }
}

Who knows what to do?

1 Answer 1

5

Try changing NgReduxRouterModule to NgReduxRouterModule.forRoot()

Sign up to request clarification or add additional context in comments.

2 Comments

Beautiful answer. Fixed the error immediately. Can you explain the reason for the change @Nikola Gavric ? Just if you have time :)
Hi, sorry for the late response, here is a nice article explaining the use for forRoot => angularfirst.com/the-ngmodule-forroot-convention

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.