Javascript Angular2:儿童的递归路径
在Angular 2中,有这样一条路线:Javascript Angular2:儿童的递归路径,javascript,angular,angular-routing,Javascript,Angular,Angular Routing,在Angular 2中,有这样一条路线: { path: 'contents/:id', component: ContentComponent } 当访问I/contents/1时,这种方法非常有效。 假设ContentComponent有很多ContentComponent子级,换句话说,内容有很多内容 有没有可能使这条路线与孩子们递归? 比如:/contents/1/contents/20、/contents/1/contents/20/contents/54、/contents/1/c
{ path: 'contents/:id', component: ContentComponent }
当访问I/contents/1时,这种方法非常有效。
假设ContentComponent有很多ContentComponent子级,换句话说,内容有很多内容
有没有可能使这条路线与孩子们递归?
比如:/contents/1/contents/20、/contents/1/contents/20/contents/54、/contents/1/contents/20/contents/54/contents/34324你试过使用children吗
{
path: 'contents/:id',
component: ContentComponent,
children: [
path: 'contents/:id',
component: AnotherContentComponent,
]
}
路由有一个子路由:[],其中包含子路由。然而,你必须为此设计你的应用程序,以实现你的目标:
{ path: 'contents/:id', component: ContentComponent, children:[
{path:'child1', component:TheChild1Component, children:[ {nested child route}]},
{path:'child2', component:TheChild2Component, children:[ { another nested child route}]}
...
] }
问题是“再次嵌套子路由”:我不知道将有多少层。它必须是递归的,但我不知道his是否可行。问题是“再次嵌套子路由”:我不知道将有多少层。它必须是递归的,但我不知道这是否可行。@ChristianBenseler嵌套路由由
angular2
中的子级处理。我不知道你说的递归是什么意思。到目前为止,你找到什么解决方案了吗???@SadokMtir没有。我更改了我的应用程序以避免嵌套和递归路由。现在它们都是“普通的”:/{modelname}/{id},我避免使用/{modelname}/{id}/{anothermodelname}/{otherid}