Getting 'this._ngZone is undefined' error in StackBlitz

108 views Asked by At

I'm trying to run an angular app inside StackBlitz. It was working fine, until I tried adding a mat-sidenav-container. Then the app started failing with the following error displayed in the console:

ERROR Error: this._ngZone is undefined

Here's the link to the StackBlitz in question: https://stackblitz.com/edit/angular-7cazwh?file=src%2Fapp%2Fapp.component.html

Here's the html code. If I comment out specified part, it works. How do I get it to work? Thanks.

<div class="main-div">
  <mat-toolbar color="primary" class="app-header">
    <button mat-icon-button (click)="toggleSidenav()">
      <mat-icon>menu</mat-icon>
    </button>
    <span>Config</span>
    <span class="spacer"></span>
    <button mat-icon-button>
      <mat-icon>account_circle</mat-icon>
    </button>
    <span>Admin</span>
  </mat-toolbar>
  
  <!-- NOTE: the app works when I comment out mat-sidenav-container below -->
  <mat-sidenav-container class="app-sidenav">
    <mat-sidenav #sidenav mode="side" opened="true" class="sidenav" fixedInViewport="false">
      <mat-list>
        <mat-list-item>
          <mat-icon matListIcon>people</mat-icon>Users
        </mat-list-item>
        <mat-list-item>
          <mat-icon matListIcon>devices_other</mat-icon>Devices
        </mat-list-item>
      </mat-list>
    </mat-sidenav>
    <mat-sidenav-content>
      <p style="margin:20px">TODO: mat-sidenav-content</p>
    </mat-sidenav-content>
  </mat-sidenav-container>

</div>
1

There are 1 answers

0
Fatih On BEST ANSWER

Seems like this a bug with Angular and Material, which remains unsolved.

Change mat-sidenav to mat-drawer.