I am encountering some challenges while setting up the auxiliary route in Angular 17, likely stemming from the transition to standalone components. Below is my current configuration:
export const FEATURE_ROUTES: Routes = [
{
path: '',
component: ContactComponent,
children: [
{
path: '',
pathMatch: 'full',
redirectTo: 'contact',
},
{
path: 'education',
component: EducationComponent,
// loadComponent: () =>
// import('./modules/education/education.component').then(
// (c) => c.EducationComponent
// ),
outlet: 'modal',
},
],
},
];
export const routes: Routes = [
{
path: 'contact',
loadChildren: () => import('./feature.routes')
.then((r) => r.FEATURE_ROUTES),
},
{
path: 'skills',
outlet: 'modal',
loadComponent: () => import('./modules/skills/skills.component')
.then((s) => s.SkillsComponent),
},
];
The routing configuration is imported in main.ts following the new Angular guidelines.
app.component.html
<button (click)="navigateToContact()">Open contact</button>
<router-outlet></router-outlet>
<div class="modal-outlet">
<router-outlet name="modal"></router-outlet>
Navigating to the contact page functions as expected.
public navigateToContact(): void {
this.router.navigate(['contact']);
}
contact.component.html
<button (click)="loadEducation()">Load educations</button>
<router-outlet></router-outlet>
<router-outlet name="test"></router-outlet>
Below is the loadEducation
method:
public loadEducation(): void {
this.router.navigate([
'/',
{ outlets: { modal: ['contact', 'education'] } },
]);
// this.router.navigate(['contact/education']);
}
I aim to achieve a functional URL structure:
http://localhost:4200/contact(modal:education)
But I am running into the error below:
Error: NG04002: Cannot match any routes. URL Segment: 'contact/education'