我的孩子模块路线如下网址参数冲突,角2路线与其他路线
{
path: '',
children: [
{ path: '', component: TripManagerComponent },
{ path: ':id', component: TripDetailComponent },
{ path: 'new', component: TripNewComponent }
]
}
要前往这些路线如下,
navigateToTrip(index: number) {
this.router.navigate([index], { relativeTo: this.route });
}
navigateToNewTrip() {
this.router.navigate(['new'], { relativeTo: this.route });
}
但角检测new
路线作为:id
并导航到TripDetailComponent
。
这里的问题是Angular为:id
路由检测到'new'字符串作为url参数。
我可以添加一个前缀到:id
,即view/:id
并使这项工作。但是,我需要保持url模式。有没有办法做到这一点?
我的预期URL模式,
/trips --> show all trips
/trips/2334 --> show details of trip 2334
/trips/new --> show a form to create a new trip
感谢Günter。有用。从来没有想过订单会很重要。 –
路线顺序总是让我:|感谢澄清这一点。 – moeabdol