What I want to do is, I want to load the home component
and sidebar component
at the same time.
const appRoutes: Routes = [
{
path: '', component: HomeComponent, children: [{
path: 'sidebar', component: SidebarComponent, children: [
{ path: 'about', component: AboutComponent },
{ path: 'clients', component: ClientsComponent },
{ path: 'services', component: ServicesComponent },
{ path: 'contact', component: ContactComponent },
{ path: 'datatable', component: DataComponent }
]
}]
}
You can use named outlets:
const appRoutes: Routes = [
{
path: '', component: HomeComponent, children: [
{ path: 'about', component: AboutComponent },
{ path: 'clients', component: ClientsComponent },
{ path: 'services', component: ServicesComponent },
{ path: 'contact', component: ContactComponent },
{ path: 'datatable', component: DataComponent }
]
},
{ path: '', component: SidebarComponent, outlet:'secondary' }
]
HTML:
<router-outlet></router-outlet> //primary outlet
<router-outlet name="secondary"></router-outlet> //secondary outlet