在子路由中具有路由模块

时间:2020-04-06 10:39:57

标签: angular angular-router

我有以下设置
app.module

...
RouterModule.forRoot([
  {path: 'w', loadChildren: () => import(<path>).then(m => m.WorkspaceModule)}
])
...

workspace.module

RouterModule.forChild([
  {
    path: ':id', component: WorkspaceComponent,
    children: [
      ...
      {path: 'profile', component: ProfileComponent},
      ...
    ]
  }
])

问题是,我在WorkspaceModule中有很多不同的子路由,但我不想在那里像profile那样声明所有子路由,而在{内定义了配置文件路由{1}}。

如果这样做, ProfileModule

workspace.module

ProfileModule, RouterModule.forChild([ { path: ':id', component: WorkspaceComponent, } ])

profile.module

然后尝试路由到RouterModule.forChild([ { path: 'profile', component: ProfileComponent, } ]) ,但我收到一条错误消息,指出没有与我尝试的路径匹配的路径,原因是这样的配置文件路径显然是/w/<userId>/profile
我不能延迟加载这些功能模块的大部分。

我想念什么? 谢谢。

编辑:对不起,我认为自己表达不正确。

我要寻找的是一种在/profile中声明我的profile路由并将其用作ProfileModule的子级路由的一种方法,而不必在{{ 1}}的{​​{1}}声明,因为它太乱了。

0 个答案:

没有答案