Abonnez-vous Observables valeur

Quand je suis à la journalisation de la valeur de ma variable à l'intérieur de la abonnez-vous, j'ai une valeur, mais en la faisant à l'extérieur, je reçois indéfinis ???:

this._postService.getConf("app/conf/conf.json")
   .subscribe(res =>{
      this.home = JSON.stringify(res);
      console.log("value :" + this.home);

je veux initialiser mon domicile variable avec une certaine valeur, je le fais sur ngOnInit mais il d'obtenir la valeur undefined quand je suis en train de l'obtenir à l'extérieur:

C'est ma fonction :

getConf(url) {
   return this._http.get(url).
      map(res => {return res.json()});
}

ngOnInit() {

  this._postService.getConf("app/conf/conf.json")
   .subscribe(res => {
        this.home = JSON.stringify(res);
        console.log("hahowaaaaaaaa" + this.home);
   }
  );

  this._postService.getPosts(this.home)
  .subscribe(result =>{ 
    this.loading = false;
    this.actionsG = result; 
    var count = JSON.stringify(result);

    this.aCount = count.substring(count.indexOf(','),23);

  },error=> console.error('Error: ' + error), ()=> console.log('finish! ActionsG'));

  this._postService.getPosts(this.home ).subscribe(result => this.actionsV = 
    result, error=> console.error('Error: ' + error), ()=> console.log('finish! ActionsV ngOnInit' + this.page));
}

OriginalL'auteur Anna | 2016-07-06