Having a sidebar containing links at the /dashboard
route, where these links serve as direct children to /dashboard
. The goal is to render these children of /dashboard
within the main router-outlet
, but unsure of how to proceed. Below are code snippets illustrating the issue:
Reviewing the Routing Structure
const routes: Routes = [
{
path: '',
component: LoginComponent,
},
{
path: 'dashboard',
component: DashboardComponent,
children: [
{
path: 'roles',
component: RolesComponent,
},
{
path: 'workgroups',
component: WorkgroupsComponent,
children: [
{
path: 'savewg',
component: WgDetailsComponent,
},
]
},
{
path: 'users',
component: UsersComponent,
},
],
},
];
Main App Component Structure
<!-- Main app component -->
<div class="app-view">
<router-outlet></router-outlet>
</div>
Login.html Implementation
<button mat-raised-button color="warn" class="login-field" (click)="login(email, password)"
<!-- rest of the code omitted for brevity -->
Login.ts Functionality
public login(email: string, password: string) {
this.router.navigate(['dashboard'], { replaceUrl: true });
}
Workgroup Component HTML Section
<button mat-raised-button color="warn" [routerLink]="['savewg']">
<mat-icon>add</mat-icon>
New
</button>
<!-- Code omitted for brevity ... -->
<router-outlet></router-outlet>
<div class="workgroup-filters">
<mat-form-field appearance="outline">
<!-- remaining code omitted for brevity -->
- Desiring the ability for the
New
button in theworkgroup
component to navigate to thesavewg
component view and replace the content within theworkgroup
component. - Grateful for any suggestions on addressing this challenge.