Angular Material Sidebar - How to trigger paint toggle in another component?

Jonathan Lightbringer

The button is in the navbar, which is in a different component than the sidebar. My layout looks like this:

<mat-sidenav-container class="sidenav-container">
  <mat-sidenav #drawer
    [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
    [mode]="(isHandset$ | async) ? 'over' : 'side'"
    [opened]="!(isHandset$ | async)">

On the navbar I have the following buttons:

<button mat-icon-button (click)="drawer.toggle()">
Papa Pacho

You can either make the sidebar a child component of the navbar or you can @ViewChild('drawer') drawer: ElementRef;create a toggle class in the sidebar component and then use @ViewChild(SidebarComponent) child: SidebarComponent;in the navbar component and then usethis.child.'class_in_sidebar'