Update
I made the switch from forRoot
to forChild
based on the responses received.
Essentially, I have two issues to address. Let's consider this as a submodule:
@NgModule({
imports: [
CommonModule,
ARoutingModule,
BModule
],
declarations: [AppsComponent, ...],
exports: [
AppsComponent, ...
]
})
export class AModule { }
and
@NgModule({
imports: [
CommonModule,
BRoutingModule
],
declarations: [AppsComponent, ...],
exports: [
AppsComponent, ...
]
})
export class BModule { }
Hence, AModule
is imported by the root module, and both modules, AModule
and BModule
, are required to define their own routes. For instance,
// ./A/A-Routing.module.ts
const routes: Routes = [
{
path: 'A',
component: AComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: []
})
export class ARoutingModule { }
Additionally, in the subsub section we have
// ./A/B/B-Routing.module.ts
const routes: Routes = [
{
path: 'B',
component: BComponent,
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: []
})
export class BRoutingModule { }
Is it viable to achieve this? Utilizing a path printing tool, I can access the sub-routes but not the subsub routes (i.e., B). Can I establish the routes in B without prior information about the preceding path? In other words, defining route for else
without knowledge of something
?
If interested, you can view an example using Stackblitz here. While main
functions properly, the Subs
encounter difficulties...