gpt4 book ai didi

angular - NullInjectorError : No provider for RouterStateSerializer

转载 作者:行者123 更新时间:2023-12-03 23:28:16 25 4
gpt4 key购买 nike

我已经将一个小项目从 angular 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 .提前致谢!

最佳答案

从 6 到 8,StoreouterConnectingModule 的导入语句略有变化,您需要调用 ngrx 文档 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 {}

关于angular - NullInjectorError : No provider for RouterStateSerializer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56773352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com