Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error after updating to angular 5: No provider for NgReduxRouter

Tags:

angular

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?

like image 384
Taladan Avatar asked Feb 13 '18 22:02

Taladan


1 Answers

Try changing NgReduxRouterModule to NgReduxRouterModule.forRoot()

like image 112
Nikola Gavric Avatar answered Oct 16 '22 09:10

Nikola Gavric