I'm trying to give a name to the router-outlet but it is not working.
This is the basic routing that works perfectly:
routing module
@NgModule({
imports: [
RouterModule.forChild([
{
path: 'admin',
component: AdminComponent,
children: [
{
path: '',
redirectTo: 'dashboard1',
pathMatch: 'full'
},
{
path: 'dashboard1',
component: AdminDashboard1Component
},
{
path: 'dashboard2',
component: AdminDashboard2Component
}
]
}
])
],
exports: [
RouterModule
]
})
export class AdminRoutingModule { }
component html
<div class="wrapper">
<app-admin-header></app-admin-header>
<!-- Left side column. contains the logo and sidebar -->
<app-admin-left-side></app-admin-left-side>
<!-- Content Wrapper. Contains page content -->
<router-outlet></router-outlet>
<!-- /.content-wrapper -->
<app-admin-footer></app-admin-footer>
<!-- Control Sidebar -->
<app-admin-control-sidebar></app-admin-control-sidebar>
<!-- /.control-sidebar -->
</div>
Now I want to give a name to the router-outlet in order to implement some customizations but it doesen't work.
If I apply this changes:
<router-outlet name='one'></router-outlet>
and:
imports: [
RouterModule.forChild([
{
path: 'admin',
component: AdminComponent,
children: [
{
path: '',
redirectTo: 'dashboard1',
pathMatch: 'full'
},
{
path: 'dashboard1',
component: AdminDashboard1Component,
outlet:'one'
},
{
path: 'dashboard2',
component: AdminDashboard2Component
outlet:'one'
}
]
}
])
]
The routing is not working:
/admin : the application is loaded but noone component is injected
/admin/dashboard1 : the application is not loaded and I get this error in console: Error: Cannot match any routes. URL Segment: 'admin/dashboard1'
Thanks to support