title: How correctly load settings to my angular2 app
body: <p>I'm trying to do the initialization settings, but it seems that I am doing something wrong</p>
  
  <p><strong>main.service.provider.ts</strong></p>
  
  <pre><code>import {Injectable} from "@angular/core";
  import {Http, Response} from '@angular/http';
  import {Observable}     from 'rxjs/Observable';
  import "../lib/lib";
  @Injectable()
  export class MainServiceProvider {
    private _settings: any;
    private _error: boolean;
  
    constructor(private http: Http) {
      this._error = false;
  //try load settings here
      this._getsettings().subscribe(
        resp =&gt; {
          console.log(resp);
          this._settings = resp
        },
        error =&gt; {
          console.error(error);
          this._error = true;
        }
      );
    }
  
  
    //main request to server function
    public getData(citieslist: Array&lt;string&gt;): Observable&lt;Object&gt; {
      if ((typeof  citieslist === 'object') &amp;&amp; (citieslist.length &gt; 0)) {
        let adressarray: Array&lt;any&gt; = [];
        for (let city of citieslist) {
          let url = this._settings.url + this._settings.searchparam + city;
          adressarray.push(this.http.get(url).map((res: Response) =&gt; this._extractData(res)).catch(this._handleError))
        }
        return Observable.forkJoin(adressarray)
      }
      else
        console.error('no valid data in function parameter');
    }
    //data handler
    private _extractData(res: Response) {
  
      let body = res.json();
      return body || {};
    }
    //error handler function
    private _handleError(error: any) {
  
      let errMessage = (error.message) ? error.message :
        error.status ? `${error.status} - ${error.statusText}` : 'server error';
      console.error(errMessage);
      return Observable.throw(errMessage);
    }
    //settings getter
    public _getsettings(): Observable&lt;Object&gt; {
      return this.http.get('/data/settings.json').map((res: Response) =&gt; this._extractData(res)).catch(this._handleError);
    }
  }
  </code></pre>
  
  <p>In app.component i subscribing on  GetData function in ngOnInit
  As result: when i start app, GetData execute first and not seen settings in main.service.provider</p>