Skip to content

Instantly share code, notes, and snippets.

@reiosantos
Created February 7, 2019 14:23
Show Gist options
  • Save reiosantos/41fb1726c15d5b42456fd925f0a26c08 to your computer and use it in GitHub Desktop.
Save reiosantos/41fb1726c15d5b42456fd925f0a26c08 to your computer and use it in GitHub Desktop.
Angular Navigation menu toggle service with @angular/material
import { Injectable } from '@angular/core';
import { MatSidenav } from '@angular/material';
@Injectable({
providedIn: 'root'
})
export class NavMenuService {
private sidenav: MatSidenav;
public setSidenav(sidenav: MatSidenav) {
this.sidenav = sidenav;
}
public open() {
return this.sidenav.open();
}
public close() {
return this.sidenav.close();
}
public toggle(): void {
this.sidenav.toggle();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment