更新为角度5后出错:NgReduxRouter没有提供者

时间:2018-02-13 22:06:35

标签: angular

更新到Angular 5后,我的商店模块收到错误消息。 Angular-Redux现在有版本7.1.0

  

未处理的承诺拒绝:StaticInjectorError(AppModule)[StoreModule - > NgReduxRouter]:   StaticInjectorError(Platform:core)[StoreModule - > NgReduxRouter]:      NullInjectorError:没有NgReduxRouter的提供者! ;区域:;   任务:Promise.then;值:错误:   StaticInjectorError(AppModule)[StoreModule - > NgReduxRouter]:
  StaticInjectorError(Platform:core)[StoreModule - > NgReduxRouter]:       NullInjectorError:没有NgReduxRouter的提供者!       在_NullInjector.get [...]

在这里,您可以看到我的商店模块

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);
    }
}

谁知道该怎么做?

1 个答案:

答案 0 :(得分:5)

尝试将NgReduxRouterModule更改为NgReduxRouterModule.forRoot()