我想在调用方法start.toggle()
时启动函数(属于 Angular 2 材质 md-sidenav-layout 组件)test()
。如何start.toggle()
在app.component.ts中调用 md-sidenav-layout ?
app.component.html
<md-sidenav-layout class="sidenav" fullscreen>
<md-sidenav #start>
Start Side Drawer
<br>
<md-nav-list>
<a md-list-item [routerLink]="['']">Home</a>
<a md-list-item [routerLink]="['about']">About</a>
</md-nav-list>
<button md-button (click)="start.close()">Close</button>
</md-sidenav>
<div class="content">
<button md-button (click)="start.toggle()">Toggle Start Side Drawer</button>
<button md-button (click)="test()">Test Button</button>
<main>
<router-outlet></router-outlet>
</main>
<footer>
</footer>
</div>
</md-sidenav-layout>
app.component.ts
import {Component} from '@angular/core';
// what to import here?
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
constructor() {
}
test() {
// how to call md-sidenav-layout start.toggle() properly here?
start.toggle();
}
}