loadChildren
):
Directory structure
app
|-foo
| |- foo.module
| |- ... (foo components)
|-bar
| |- bar.module
| |- ... (bar components)
AppRouting.ts
export const AppRoutes: Routes = [
{ path: '', loadChildren: './foo/foo.module#FooModule' },
{ path: 'bar', loadChildren: './bar/bar.module#BarModule' }
];
FooRouting.ts
export const FooRoutes: Routes = [
{ path: '', component: ManageComponent },
{ path: ':id', component: DetailsComponent },
{ path: 'list', component: ListComponent },
{ path: '**', component: FooErrorNotFoundComponent }
];
BarRouting.ts
export const BarRoutes: Routes = [
{ path: '', component: WorkspaceComponent },
{ path: 'view', component: ViewComponent },
{ path: 'another', component: AnotherComponent },
];
My problem is this:
- I need each sub-module to have its own error screen, because its subcomponents can change like navigation bars, etc ...
- When I use the above structure and try to access the url
localhost:300/bar/view
, Angular is directing me to the Foo error page, that is, it is not initially respecting the AppRouting routes and going straight to Foo. > - If I remove the Foo error page, then yes the Angular directs me to the Bar sub-module.
How can I keep the Foo module error page but forcing the Angular to respect the initial structure of the App routing?