title: How to execute something after subscribe in angular
body: <p>I want to return a boolean value ,but the variable in the "if" condition is undefined. </p>
  
  <pre><code>function() {
      this.menuDataService.getMenu()
        .subscribe(res =&gt; {
         this.mainMenus = res.MainMenus;
         console.log(this.mainMenus);
      });
  
      console.log(this.mainMenus);
  
      if(this.mainMenus == 1){
         return true;
      }
      else {
        return false;
      }
  }
  </code></pre>