title: How to wait for a observable method to finish before proceeding in Angular 2
body: <p>I am new to Angular and I am working on fixing something that is written in Angular 2. In the method we have a call to to observable method after that we are assigning a value to a variable. I need the obersavable method to finish execution before assigning the value. Given below is the code for your reference.</p>
  <pre><code>Method1(): void {
       this.Service.getData()
          .subscribe(
          res =&gt; {
            
          },
          error =&gt;  this.errorMessage = &lt;any&gt;error);
          this.gotData = true;
  }
  </code></pre>
  <p>So, As shown above, I need to assign true to gotData variable after the getData Observable method is finished execution. But gotData is getting assigned true even before we actually get the data.</p>
  <p>Please help me who to wait until the observable method is finished execution. Thank you !</p>