我们可以使用不同路由组件的相同路径 - Angular Routing

Can we have same path with different routing component - Angular Routing

我有一个 component,它呈现了一些子路由集,但布局不同 - 我们可以为两个布局使用相同的路径名吗,如下所示

{
    path: '',
    component: LandingComponent,
    children: [
      { path: '', component: LandingpageComponent },
      { path: 'landingpage', component: LandingpageComponent },
    ]
  },
  {
    path: '',
    component: DashboardComponent,
    children: [
      { path: 'patients', component: PatientsComponent },
      { path: 'endrolPatient', component: ProfileComponent },
      { path: 'endrolPatient/:id', component: ProfileComponent },

    ]
  }

在上面的示例中,路径名是相同的 - 当我 运行 应用程序时,我可以看到输出 - angular 如何使用这种关闭路由。

是的,你可以!

基本上,根据 Angular 路由器结构,同一组件可以有多个路由器路径。

假设您想使用组件 A 和两个链接,如下所示 -

abc.com/first
abc.com/second

在这种情况下,您可以使用相同的组件。