角2不同的模块相同的路由

问题描述:

我有两条主要路线,两个路线都装载相同的子模块.是否有可能在子模块上具有两个具有相同名称的路由,从而相对于主路由加载两个不同的组件.

I am having two main routes, both loading same child module. Is there any possible way to have two routes with same name on the child module that loads two different components with respect to the main route.

主要路线:

export const ROUTES: Routes = [{
    path: 'first',
    loadChildren: './features/common#CommonModule',
    canActivate: [AppAuthGuard]
}, {
    path: 'second',
    loadChildren: './features/common#CommonModule',
    canActivate: [AppAuthGuard]
}]

现在我希望通用模块具有这样的路由

Now I'm expecting the common module to have routes something like this

export const routes = [{
        path: 'list', component: FirstListComponent, pathMatch: 'full' }
    },{
        path: 'list', component: SecondListComponent, pathMatch: 'full' }
    }]

所以,我想要类似的东西

So, I want something like

  • 如果路由为 first/list ,则应加载 FirstListComponent .
  • 如果路由为 second/list ,则应加载 SecondListComponent .
  • If route is first/list, then FirstListComponent should be loaded.
  • If route is second/list, then SecondListComponent should be loaded.

我知道路线的顺序很重要.并且提出的方法是不可能的.任何人都可以提出任何可能的方法来实现这一目标.

I know that the order of the routes matters. And the proposed way is not possible. Can anyone suggest any possible way to achieve this.

请设置这样的路径

export const routes = [{
        path: 'first/list', component: FirstListComponent, pathMatch: 'full' }
    },{
        path: 'second/list', component: SecondListComponent, pathMatch: 'full' }
    }]