I use material-sidebar
for showing the mobile menu.
I want to close sidebar when any of item in the menu is clicked.
I send out by the EventEmmiter()
function to close the sidebar from child to parent controller.
public onSidenavClose = () => {
this.sidenavClose.emit();
};
And here in app.component.html I set like this
<mat-sidenav-container fxFlexFill>
<mat-sidenav #sidenav (sidenavClose)="sidenav.close()">
<mat-nav-list>
<app-nav-item></app-nav-item>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content fxFlexFill>Main content</mat-sidenav-content>
</mat-sidenav-container>
But can not get to close sidebar... some solution?
Here is full working example. You need to resize opened preview in stackblitz to get the mobile nav.