2016-09-21 5 views
1

に加入したデータの値を取得するにはどうすれば私は私のデータに「表示」を返すしたいの注射サービスを書き、次のように私はここはangular2

export class GetAllList { 
    str = localStorage.getItem('social'); 
    loc = JSON.parse(this.str); 
    id = this.loc._id; 
    private _productUrl = 'http://localhost:3000/getprofiledetails/'+this.id; 

    constructor(private _http: Http) { } 

    getList(): Observable<IDetails[]> { 
     return this._http.get(this._productUrl) 
    .map((response: Response) => {  
     return response.json().data.display; 

     }); 

    } 
} 

私が加入しています、sucessfullyそれを行ってこれに、

this._profileservice.getList() 
     .subscribe(
      details1 => this.details1 = details1); 
     console.log("displaystas:"+this.details) 

問題があるが、私のコンソールが未定義表示している?ので、どのように私はhelp.Thankあなた誰も私を提案することはできますか?私のコンソールの私の表示値を見ることができます。

答えて

1

あなたは(details代わりのdetails1)間違った変数を印刷していて、{}不足している:

this._profileservice.getList() 
    .subscribe(
     details1 => { 
     this.details1 = details1; 
     console.log("displaystas: " + this.details1) 
     } 
+1

おかげで、そのwrkngのNWを – klp