我正在使用
Angular Universal Starter
对于我的应用程序,我尝试从API构建一个动态路由系统。
我想在应用程序启动SRAP之前配置我的路由系统。为此,我使用
APP_INITIALISER
.我走了不同的路,尤其是这条:
Angular 5 Build routes from API data at startup
我的问题出现在我的应用程序上。单元ts文件:
export function initRoutes(routes: RouterService) {
return () => routes.browse();
}
@NgModule({
imports: [
BrowserModule.withServerTransition({appId: 'universal'}),
BrowserAnimationsModule,
RouterModule.forRoot([]),
TransferHttpCacheModule,
HttpClientModule,
InjectorModule,
HomeModule,
],
declarations: [
AppComponent,
],
entryComponents: [
HomeComponent
],
providers: [
NetworkService,
RouterService,
{
'provide': APP_INITIALIZER,
'useFactory': initRoutes,
'deps': [ RouterService ],
'multi': true,
},
Title,
MenuService
],
bootstrap: [AppComponent]
})
当我导入时
TransferHttpCacheModule
(对于在服务器端呈现应用程序时已经发出的请求,一个拦截器可以避免在客户端上重复HttpClient请求),我得到以下错误:
enter image description here
我的问题是:是否可以发送JSON(带有路由列表)来在SSR应用程序上配置我的路由系统?