如何在组件中调用角度材质 sidenav 动作?我有一个用例,sidenav 只能在callMethods()
方法触发时打开/关闭。我也不能简单地传入open(e)
(callMethods()
需要 1 个参数)。有没有办法做到这一点?
应用程序.html
<mat-sidenav-container class="example-container">
<mat-sidenav #sidenav [mode]="mode.value">
<p>
some nav here
</p>
</mat-sidenav>
<mat-sidenav-content>
<p><button mat-button (click)="open(sidenav)">Toggle</button></p>
<p>
some text here
</p>
</mat-sidenav-content>
</mat-sidenav-container>
应用程序.ts
open(e: any) {
e.toggle();
}
callMethods() {
this.open(); // required 1 arguments
this.otherMethod();
}
anotherMethod() {
this.open(); // required 1 arguments
this.otherMethod();
}
注意:我注意到有一个帖子但不清楚