I am using angular 4 in combination with angular material.
I am using a sidenav container a router and a custom generated menu:
<mat-sidenav-container>
<mat-sidenav #sidenav>
<app-menu></app-menu>
</mat-sidenav>
<router-outlet></router-outlet>
</mat-sidenav-container>
Inside the menu component I am using default angular 4 router links:
<ul>
<li *ngFor="let hero of heroes">
<a mat-button [routerLink]="['/hero/', hero.id]" queryParamsHandling="merge">
{{hero.name}}
</a>
</li>
</ul>
What I would like to do is to close the Material sidenav
when clicking on one of those router links.
I can assure you that without the click event routing works fine, it just does not close my sidenav, because the router-outlet is inside the side navigation.
However, when I add a (click)="sidenav.close()"
to the a
my full page suddenly refreshed, instead of just following the router link.
I have tried many things, but I can't seem to figure it out, hope someone can help!