我有一个使用路由器的Angular2应用程序,在 app.routes.ts
中使用标准设置模式:
const appRoutes: Routes = [
{
path: '',
redirectTo: '/login',
pathMatch: 'full'
},
{
path: 'login',
component: LoginComponent
},
...other static routes...
];
export const Routing: ModuleWithProviders = RouterModule.forRoot(appRoutes);
但我的应用程序有一些不在静态appRoutes数组中的路由 . 它们使用名为 CmsService
的可注入服务加载,该服务作为APP_INITIALIZER运行,并根据How to pass parameters rendered from backend to angular2 bootstrap method以及下面的注释将其结果存储为公共属性 CmsService.pages
.
现在我想弄清楚如何在 app.routes.ts
中使用这个服务,但我无法弄清楚这个文件实际上是什么类型的动物?我可以谷歌如何使用注射服务的例子都是针对组件的,但是 app.routes.ts
是另外的东西,我在如何在初始化路由器之前将路径从 CmsService.pages
添加到 appRoutes
阵列中感到茫然 .