import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LayoutComponent } from './layouts/layout.component';
const routes: Routes = [
{
path: '',
component: LayoutComponent,
children: [
{
path: ':id',
loadChildren: './layouts/layout.module#LayoutModule'
}
]
},
{ /* THE FOLLOWING BLOCK WORKS */
path: '',
component: LayoutComponent,
children: [
{
path: '',
loadChildren: './layouts/layout.module#LayoutModule'
}
]
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {
scrollPositionRestoration: 'enabled'
})],
exports: [RouterModule]
})
export class AppRoutingModule { }
I am attempting to create two different sets of URLs with the same layout structure. The first URL works fine at http://localhost:4200/account. However, when trying to access the second URL at http://localhost:4200/20/account, it fails and displays the error message:
core.js:5882 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '20/account'
I'm unsure where I made a mistake, can anyone assist me with this?