繁体   English   中英

Angular2:儿童的递归路线

[英]Angular2: recursive routes in children

在Angular 2中,有这样一条路线:

{ path: 'contents/:id', component: ContentComponent }

当我访问/ contents / 1时,这很完美。 假设ContentComponent有许多ContentComponent子级,换句话说,Content有许多Contents。

是否可以使此路线与孩子一起递归? 像:/ contents / 1 / contents / 20,/ contents / 1 / contents / 20 / contents / 54,/ contents / 1 / contents / 20 / contents / 54 / contents / 34324

您有没有尝试过使用孩子?

{
  path: 'contents/:id',
  component: ContentComponent,
  children: [
     path: 'contents/:id',
     component: AnotherContentComponent,
  ]
}

该路线具有子路线children:[] ,其中包含子路线。 但是,您必须为此设计应用程序,以实现所需的功能:

{ path: 'contents/:id', component: ContentComponent, children:[
  {path:'child1', component:TheChild1Component, children:[ {nested child route}]},
  {path:'child2', component:TheChild2Component, children:[ { another nested child route}]}
   ...
] }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM