title: subscribe in Angular 2
body: <p>I want my ngOnInit function do next things:
   - make http request for some data using this.structureRequest.sendRequest(),which works fine,  and after data have been received to start view it using this.viewNodes() function.
  I use subscribe , but it does not work, I think I do something wrong with subscribe function. please help:)</p>
  
  <ol>
  <li><p>HomeComponent.ts</p>
  
  <pre><code>import {Component} from '@angular/core';
  import {Observable} from 'rxjs/Observable';
  import {StructureRequestService} from './StructureRequestService';
  
  
  export class Content {
  
  
  ok: boolean;
  content = [];
  }
  @Component({
  providers: [StructureRequestService],
  styleUrls: ['app/home/home.css'],
  templateUrl:'./app/home/homePageTemplate.html'
  
  })
  
  export class HomeComponent {
  contentArray = [];
  myRes: Content;
  showAssigned:boolean = false;
  showSubitems:boolean = false;
  showUsers:boolean = false;
  
  constructor(private structureRequest: StructureRequestService) {}
  
  ngOnInit() {
  this.structureRequest.sendRequest().subscribe( this.viewNodes());
  
  }
  
  viewNodes() {
  this.myRes = this.structureRequest.result;
  this.contentArray = this.myRes.content;
  this.showAssigned = true;
   }
   }
  </code></pre></li>
  </ol>
  
  <p>2.Here is http service, http get works fine, all data received:</p>
  
  <pre><code>import {Injectable} from '@angular/core';
  import {Http, Response, Headers, RequestOptions} from '@angular/http';
  
  import {Observable} from 'rxjs/Observable';
  
  @Injectable ()
  export class StructureRequestService {
  result: Object;
  //private myUrl = 'http://manny.herokuapp.com/audit/get/structure';
  private myUrl = './app/home/nodes.json';  // local URL to structure APi
  constructor (private http: Http) {
      //use XHR object
      let _build = (&lt;any&gt; http)._backend._browserXHR.build;
      (&lt;any&gt; http)._backend._browserXHR.build = () =&gt; {
          let _xhr =  _build();
          _xhr.withCredentials = true;
          return _xhr;
      };
  }
  
  sendRequest() {
      let body = JSON.stringify({});
      let headers = new Headers({ 'Content-Type': 'application/json'});
      let options = new RequestOptions({
          headers: headers
      });
       this.http.get(this.myUrl, options)
          .map((res: Response) =&gt; res.json())
          .subscribe(res =&gt; {this.result = res;
              return this.result; });
  }
  }
  </code></pre>
  
  <p>3.so the problem is to make synchronous steps: receive data, than view it. </p>