I'm trying to change the icon of mat-icon depending on close or open mat-sidenav but unable to find if sidenav is open or close below is my code
<mat-sidenav appResponsiveMenu mode="side" opened>
my menu items list
</mat-sidenav>
here is the toggle button
<button mat-icon-button (click)="sidenav.toggle()">
<mat-icon *ngIf="sidenav">keyboard_arrow_left</mat-icon>
<mat-icon *ngIf="!sidenav">keyboard_arrow_right</mat-icon>
</button>
.ts code
@ViewChild(MatSidenav)
sidenav!: MatSidenav;
mat-sidenav component have opened input property we can use that to check whether sidenav open or not
<button mat-icon-button (click)="sidenav.toggle()">
<mat-icon *ngIf="sidenav.opened">keyboard_arrow_left</mat-icon>
<mat-icon *ngIf="!sidenav.opened">keyboard_arrow_right</mat-icon>
</button>