我已经将一个小小的侧面项目从6号角升级到8号角,现在出现了一个我不理解的错误。
StaticInjectorError(Platform: core)[StoreRouterConnectingModule -> RouterStateSerializer]:
NullInjectorError: No provider for RouterStateSerializer!
at NullInjector.get (http://localhost:4200/vendor.js:36416:27)
at resolveToken (http://localhost:4200/vendor.js:36743:24)
at tryResolveToken (http://localhost:4200/vendor.js:36669:16)
at StaticInjector.get (http://localhost:4200/vendor.js:36532:20)
at resolveToken (http://localhost:4200/vendor.js:36743:24)
at tryResolveToken (http://localhost:4200/vendor.js:36669:16)
at StaticInjector.get (http://localhost:4200/vendor.js:36532:20)
at resolveNgModuleDep (http://localhost:4200/vendor.js:58166:29)
at _createClass (http://localhost:4200/vendor.js:58243:32)
at _createProviderInstance (http://localhost:4200/vendor.js:58199:26)
有人可以看看吗,给我一些指示。可以在here中找到该代码。预先感谢!
答案 0 :(得分:1)
答案 1 :(得分:1)
从6到8,StoreouterConnectingModule
的import语句稍有变化,您需要调用ngrx docs here
forRoot()
方法
代码示例:
import { StoreRouterConnectingModule, routerReducer } from '@ngrx/router-store';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
StoreModule.forRoot({
router: routerReducer,
}),
RouterModule.forRoot([
// routes
]),
// Connects RouterModule with StoreModule
StoreRouterConnectingModule.forRoot(),
],
bootstrap: [AppComponent],
})
export class AppModule {}