子路由中的参数

3
在我的Angular 4应用程序中,我有如下路由: ticketBundles/:code/copyticketBundles/:code 我该如何路由到特定的视图,并如何检索正确的代码? 这两个页面是不同的,因此我需要加载不同的模块。
我的路由如下:
export const TicketBundleRoutes: Routes = [
  {
    path: '',
    component: TicketBundleListComponent
  },
  {
    path: 'new',
    component: TicketBundleNewComponent
  },
  {
    path: ':code',
    component: TicketBundleDetailComponent,
    children: [
      {
        path: 'copy',
        component: TicketBundleNewComponent
      }
    ]
  }
];

我该如何路由到子组件?

我知道可以使用查询参数 this.router.navigate(['/ticketBundle', this.code , {action: 'copy'}]); 但我不想要像这样格式化的路径: /ticketBundle/1;action=copy

1个回答

1
我假设你的意思是不同的组件而非不同的模块。
 [
      {
        path: 'ticketBundles/:code',
        component: TicketComponent,
        children: [
          {
            path: 'copy',
            component: SomeOtherComponent
          }
        ]
      }

]

我更新了问题。 - Alessandro Celeghin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接