title: How can I use Angular 2 Material Sidenav inside a component?
body: <p>I'm new to angular and I'm trying to understand the ropes here. The docs of the new angular 2 material are a bit confusing but I managed to add tabs and the sidenav to my app but I can't make a button to open the sidenav using my component. This example is the only reference I have for how it's done and not knowing much about it I think it's using angular 1? <a href="https://material.angularjs.org/latest/demo/sidenav" rel="nofollow">https://material.angularjs.org/latest/demo/sidenav</a></p>
  
  <p>What I have right now in my component is this:</p>
  
  <pre><code>import { Component, OnInit, OnDestroy, ElementRef, Inject } from '@angular/core';
  import { ActivatedRoute } from '@angular/router';
  import {Http, Response} from '@angular/http';
  
  import { MD_TABS_DIRECTIVES } from '@angular2-material/tabs';
  import { MD_SIDENAV_DIRECTIVES } from '@angular2-material/sidenav';
  
  @Component({
  selector: 'my-ambient-detail',
  templateUrl: 'app/ambients/ambient-detail.component.html',
  directives: [MD_TABS_DIRECTIVES, MD_SIDENAV_DIRECTIVES],
  })
  export class AmbientDetailComponent implements OnInit, OnDestroy {
  
  
  // constructor and other functions here
  
  openRightMenu(){
     //WHAT GOES HERE?
  }
  
  }
  </code></pre>
  
  <p>And in the html:</p>
  
  <pre><code>&lt;md-sidenav-layout&gt;
  
  &lt;!-- Content --&gt;
  &lt;md-content&gt;
  
      &lt;md-button (click)="openRightMenu()"&gt;
      Open Right Menu
      &lt;/md-button&gt;
  
  &lt;/md-content&gt;
  
  &lt;!-- Sidebar --&gt;
  &lt;md-sidenav md-component-id="right" class="md-sidenav-right"&gt;
  
  Sidebar content
  &lt;/md-sidenav&gt;
  &lt;/md-sidenav-layout&gt;
  </code></pre>
  
  <p>So I can't find a clear reference on how to open/close the sidenav with a button using functions in the component. Maybe I'm doing this all wrong, I built my app starting straight from the heroes tutorial in the angular website but I'm very confused between angular 1 and 2 from my searches on this topic.</p>