简体   繁体   English

在 StackBlitz 中出现“this._ngZone is undefined”错误

[英]Getting 'this._ngZone is undefined' error in StackBlitz

I'm trying to run an angular app inside StackBlitz.我正在尝试在 StackBlitz 中运行 angular 应用程序。 It was working fine, until I tried adding a mat-sidenav-container .它工作正常,直到我尝试添加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这是相关 StackBlitz 的链接: https://stackblitz.com/edit/angular-7cazwh?file=src%2Fapp%2Fapp.component.html

Here's the html code.这是 html 代码。 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>

Seems like this a bug with Angular and Material, which remains unsolved .似乎这是 Angular 和 Material 的错误,仍未解决

Change mat-sidenav to mat-drawer .mat-sidenav更改为mat-drawer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM