The html page will look like this.
Main Page
<top-navbar></top-navbar>
<router-outlet></router-outlet>
Sub Module Page
<sub-navbar></sub-navbar>
<router-outlet name='sub'></router-outlet>
on clicking navigation in top-nav bar the main route outlet will route respectively.
while clicking on sub-navbar the router-outlet [sub] will route respectively.
HTML is fine, the trick will came at writing app.routing
app.routing.ts
const appRoutes: Routes = [
{
path: 'login',
component: LoginComponent
},
{ path: 'home',
component: homeComponent,
children: [
{
path: 'module1',
component: module1Component,
children: [
{
path: 'submodule11',
component: submodule11Component,
},
{
path: '',
redirectTo: 'submodule11',
pathMatch: 'full'
}
]
},
{
path: 'module2',
component: module2omponent,
children: [
{
path: 'submodule21',
component: submodule21Component,
},
{
path: '',
redirectTo: 'submodule21',
pathMatch: 'full'
}
]
}
]
},
{
path: 'about',
component: aboutComponent
}
]
Hope it will help you.
More details https://angular.io/guide/router
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…