title: Angular 2 Returning data from subscribe
body: <p>this is my service   </p>
  
  <pre><code> countGroupByEtat(): Observable&lt;number[]&gt; {
      return this.http.get(this.url + 'GroupByEtat', { headers: this.prepareHeaders() })
          .map((res: Response) =&gt; {
              let object: Array&lt;any&gt; = [];
              let jsonResults: Array&lt;any&gt; = res.json();
              jsonResults.forEach((jsonResult) =&gt; {
                  object.push(jsonResult);
              });
              return object;
          })
  }
  </code></pre>
  
  <p>and my method</p>
  
  <pre><code>  getGroupByEtat(): number[] {
      this.serviceDossier.countGroupByEtat()
        .subscribe((data: number[]) =&gt; {
          this.objects = data;
          console.log("subsc"+ this.objects)
  
        })
      return this.objects;
    }
  </code></pre>
  
  <p>When I want to obtain the value of <code>this.objects</code> after the closing of <code>subscribe</code> I receive an array that is empty, help !</p>