I am trying to develop a homepage which toggles a sidenav which I have done successfully however, if the sidenav is closed I still want to show the icons on the lefthand side rather than icons and text (when opened). I have three components: app, header and side-nav.
The toggler is in the header component and I have created an event binder so that the Text in the sideNav disappears when toggled. This issue is that the page does not adjust as a consquence and the sidenav is still the same size but with less text. Please see code below (i've only taken snippet of code that i think are relevent to this problem).
Not sure if this is an typescript issue or something css?
header.html
<button mat-icon-button (click)="toggleSideNav()"><mat-icon>menu</mat-icon></button>
header.ts
@Output() onToggleSideNav: EventEmitter<any> = new EventEmitter();
toggleSideNav() {
this.onToggleSideNav.emit();
}
app.html
<mat-drawer-container>
<mat-drawer mode="side" [opened]=true>
<app-side-nav [isExpanded]='sideNavOpen'></app-side-nav>
</mat-drawer>
<mat-drawer-content>
<app-header (onToggleSideNav)='sideNavToggler()'></app-header>
<router-outlet></router-outlet>
</mat-drawer-content>
</mat-drawer-container>
app.ts
sideNavOpen: boolean = true;
sideNavToggler() {
this.sideNavOpen = !this.sideNavOpen
}
sidenav.html
<mat-nav-list>
<a mat-list-item routerLink="/home" routerLinkActive="list-item-active">
<mat-icon>home</mat-icon>
<h4 mat-line *ngIf="isExpanded">Home</h4>
</a>
</mat-nav-list>
sidenav.ts
@Input() isExpanded: boolean = true;