title: Undefined error Angular 2 class
body: <p>I don't know why I get a undefined error. This is the error message I get: "TypeError: Cannot set property 'state' of undefined"</p>
  
  <p>This is my code: </p>
  
  <pre><code>export class MobileMenuComponent implements OnInit {
  
  menu: any;
  
  constructor() { 
  
  
  }
  
  ngOnInit() { 
  
      this.menu.state = 'inactive';
  
      this.menu.togglemenu = function() {
  
          if (this.menu.state === 'inactive'){
  
              this.menu.state = 'active';
  
          }
  
          else {
  
              this.menu.state = 'inactive';
  
          }
  
      }
  
  }
  
  
  }
  </code></pre>