我正在使用angular2材质设计侧导航组件,我想从另一个组件触发toggle
。
侧导航的模板片段
<md-sidenav-container class="side-nav-open">
<md-sidenav #sidenav mode="side" opened="true">
<div class="">
<li><a class="" [routerLink]="['/dataSelector']">Link One</a>
</li>
</div>
</md-sidenav>
<div id="dataDisplayContainer" class="dataDisplayContainer float-left">
<router-outlet></router-outlet>
</div>
</md-sidenav-container>
标题的模板片段
<button md-button class="header-menu-button" (click)="sidenav.toggle()">
<md-icon>menu</md-icon>
</button>
在angular2材质示例中,side-nav在指令
中有触发按钮<md-sidenav #sidenav mode="side" opened="true">
<button (click)="sidenav.toggle()">
<md-icon>add</md-icon>
</button>
<div class="example-scrolling-content">Content</div>
</md-sidenav>