Is there a way to check if the sidenav
element is open? According the API documentation, there is a isOpen?
parameter, but in my case it throws an exception: EXCEPTION: Error in ./AppComponent class AppComponent - inline template:2:2 caused by: this.sidenav.isOpen is not a function
import { Component, OnInit, ElementRef } from '@angular/core';
@Component({
selector: 'app-sidebar',
template: `
<md-sidenav #sidenav mode="side" class="app-sidenav">
Sidenav
</md-sidenav>
`,
styleUrls: ['./sidebar.component.css'],
host: {
'(document:click)': 'onClick($event)',
}
})
export class SidebarComponent implements OnInit {
constructor(private sidenav: ElementRef) { }
ngOnInit() {
}
onClick() {
if (this.sidenav.isOpen()) {
this.sidenav.close();
}
}
}