My child module paths are as follows:
{ path: '', children: [ { path: '', component: TripManagerComponent }, { path: ':id', component: TripDetailComponent }, { path: 'new', component: TripNewComponent } ] }
I navigate these routes as follows:
navigateToTrip(index: number) { this.router.navigate([index], { relativeTo: this.route }); } navigateToNewTrip() { this.router.navigate(['new'], { relativeTo: this.route }); }
But Angular defines the new
route as :id
and takes me to TripDetailComponent
.
The problem here is Angular defines a new line as the url parameter for the route :id
.
I could add a prefix to :id
, i.e. view/:id
and do the job. But I need to save the url template as is. Is there any way to do this?
My expected url pattern,
/trips --> show all trips /trips/2334 --> show details of trip 2334 /trips/new --> show a form to create a new trip
source share