加载路由器插座时调用父组件功能

时间:2019-08-05 17:54:57

标签: angular

我已经创建了一个带有侧栏的导航边栏,该侧栏名为sidenav.toggle(),但是当我在路由器插座中加载组件时,它不再起作用。

加载路由器出口时,如何从父组件中调用父组件中的元素?

app.component:

    <mat-sidenav-container [class.m2app-dark]="isDarkTheme">

  <mat-sidenav #sidenav mode="over" class="app-sidenav" color="primary">
    <mat-toolbar>
      <mat-toolbar-row>
          <mat-icon>account_circle</mat-icon> Account
      </mat-toolbar-row>
      <mat-toolbar-row>
          <mat-icon>settings</mat-icon> Instellingen
      </mat-toolbar-row>
    </mat-toolbar>
  </mat-sidenav>
  <mat-toolbar color="primary">
    <button mat-button class="app-menu-button" (click)="sidenav.toggle()">
      <i class="material-icons">menu</i>
    </button>
    <mat-slide-toggle (change)="isDarkTheme = !isDarkTheme"></mat-slide-toggle>

</mat-toolbar>
  <div class="app-content">
      <router-outlet></router-outlet>
  </div>
</mat-sidenav-container>

AuthComponent.html:11 ERROR TypeError: Cannot read property 'hasError' of undefined
    at Object.eval [as updateDirectives] (AuthComponent.html:12)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:36043)
    at checkAndUpdateView (core.js:35055)
    at callViewAction (core.js:35421)
    at execComponentViewsAction (core.js:35349)
    at checkAndUpdateView (core.js:35062)
    at callViewAction (core.js:35421)
    at execEmbeddedViewsAction (core.js:35378)
    at checkAndUpdateView (core.js:35056)
    at callViewAction (core.js:35421)

0 个答案:

没有答案