I'm new in Angular. I need to use the same router link in my mat-list-item
as in the sub mat-sidenav-content
.
For example:
[routerLink]="['/list',{outlets: {sidebar: ['general', employee.userId]}}]
Is the correct link which I also need to be the same link inside sub mat-sidenav-content
. Instead I have the following router link, which is not correct:
[routerLink]="['/list',{outlets: {sidebar: ['general', userId]}}]
.
I have no idea how to accomplish this and would appreciate any help solving this problem. Thank you.
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" fixedInViewport [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'" [mode]="(isHandset$ | async) ? 'over' : 'side'" [opened]="(isHandset$ | async) === false">
<mat-toolbar>List of Employee</mat-toolbar>
<mat-nav-list>
<div *ngFor="let employee of employees">
<mat-list-item>
<a [routerLink]="['/list',{outlets: {sidebar: ['general', employee.userId]}}]">{{employee.firstName}}
</a>
</mat-list-item>
</div>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="accent" class="navbar">
<span><a mat-list-item [routerLink]="['/list',{outlets: {sidebar: ['general', userId]}}]">
<mat-icon>assignment_ind</mat-icon>General
</a></span>
<span><a mat-list-item [routerLink]="['/list',{outlets: {sidebar: ['vehicleInformation', userId]}}]">
<mat-icon>directions_car</mat-icon>Vehicle Information
</a></span>
<span> <a mat-list-item [routerLink]="['/list',{outlets: {sidebar: ['OLOUserRights']}}]">
<mat-icon>vpn_key</mat-icon>OLO User Rights
</a></span>
</mat-toolbar>
<router-outlet name="sidebar"></router-outlet>
</mat-sidenav-content>