After adding a named second route, I encountered an issue when trying to navigate to a specific page.
Here is the configuration of my routes:
const appRoutes: Routes = [
{ path: '', redirectTo: '/projects', pathMatch: 'full' },
{ path: 'projects', component: ProjectsComponent },
{ path: 'projects/:projectId', component: ProjectDetailsComponent },
{ path: 'projects/:projectId/routes', component: RoutesComponent, outlet: 'project' },
{ path: 'projects/:projectId/rides/new', component: AddRideComponent, outlet: 'project' },
{ path: 'projects/:projectId/routes/:id', component: RideDetailsComponent, outlet: 'project' },
{ path: 'projects/:projectId/stops', component: StopsComponent, outlet: 'project' },
{ path: 'projects/:projectId/stops/new', component: AddStopComponent, outlet: 'project' },
{ path: 'projects/:projectId/stops/:id', component: StopDetailsComponent, outlet: 'project' },
{ path: 'drivers', component: DriversComponent },
{ path: 'drivers/new', component: AddDriverComponent },
{ path: 'drivers/:id', component: DriverDetailsComponent },
{ path: 'settings', component: SettingsComponent }
];
This is how my named router-outlet
is defined:
<router-outlet name="project"></router-outlet>
And this is what my routerLink
looks like:
<a [routerLink]="[{ outlets: { project: ['projects', projectId, 'routes'] } }]">Routes</a>
Upon hovering over the link, the url displayed is
http://localhost:4200/projects/99979de9-264c-278f-d7b4-6dec9a830974/(project:projects/99979de9-264c-278f-d7b4-6dec9a830974/routes)
However, upon clicking the link, the following error is generated:
ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'projects/99979de9-264c-278f-d7b4-6dec9a830974'
Error: Cannot match any routes. URL Segment: 'projects/99979de9-264c-278f-d7b4-6dec9a830974'
at ApplyRedirects.webpackJsonp.../../../router/@angular/router.es5.js.ApplyRedirects.noMatchError (router.es5.js:1342)
at CatchSubscriber.selector (router.es5.js:1317)
at CatchSubscriber.webpackJsonp.../../../../rxjs/operator/catch.js.CatchSubscriber.error (catch.js:104)
at MapSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._error (Subscriber.js:128)
at MapSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.error (Subscriber.js:102)
at MapSubscriber.webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._error (Subscriber.js:128)
What am I missing in my setup?