請問我的side nav 為可不懂關閉呢?
這是我的app.component.html:
<mat-sidenav-container>
<mat-sidenav #sidenav [(opened)]="isShowing">
<mat-nav-list>
<a mat-list-item [routerLink]="'/accounts'"> Accounts </a>
<a mat-list-item [routerLink]="'/create-account'"> Create Account </a>
<a mat-list-item [routerLink]="'/contacts'"> Contacts </a>
<a mat-list-item [routerLink]="'/create-contact'"> Create Contact </a>
<a mat-list-item [routerLink]="'/activities'"> Activities </a>
<a mat-list-item [routerLink]="'/create-activity'"> Create Activity </a>
<a mat-list-item (click)="toggleSidenav()" href="" mat-list-item>Close</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<div style="height: 100vh;">
<a mat-list-item (click)="toggleSidenav()" href="" mat-list-item>☰</a>
<router-outlet></router-outlet>
</div>
</mat-sidenav-content>
</mat-sidenav-container>
這是我的app.component.ts:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
isShowing = true;
toggleSidenav() {
this.isShowing = !this.isShowing;
}
}