2016-05-12 1 views
0

にJSONレスポンスを表示することはできません私は、JSONレスポンスを表示しようとしているが、何も表示するように見えることはできません。イオン2:ビュー

応答:

enter image description here

woo.service。 TS:

getProducts() : Observable<any> { 
    let headers = new Headers(); 
    headers.append('Content-Type', 'application/x-www-form-urlencoded'); 
    return this._http.get(this._url+'products?'+'consumer_key='+this._ck+'&consumer_secret='+this._cs, { 
     headers : headers 
    }).map(res => res.json().items); 
} 

woo.ts:

ngOnInit() { 
     this._wooService.getProducts() 
     .subscribe(
      response => this.response = response, 
      error => console.log(error)); 
      this.isLoading = false; 
    } 

そして最後にwoo.html:

<ion-card-header class="cardHead" text-center> 
    <h2 class="cardHeaderText">{{obj.products.title}}</h2> 

     <p>Prix: {{obj.price_html}}</p> 
</ion-card-header> 

<ion-card-content> 
    <img src="{{obj.images.src}}"> 
    <p class="cardBodyText">{{obj.description}}</p> 
    <p>Tags: {{obj.tags}}</p> 
    <p>Catégories: {{obj.categories}}</p> 
</ion-card-content> 

誰もが、私は* ngFor = "応答の#のOBJ" にアクセスすることはできませんなぜアイデアを持っていますか?

答えて

2

私はあなたの問題はここにあると思う:

​​

の代わり:

return this._http.get(this._url+'products?'+'consumer_key='+this._ck+'&consumer_secret='+this._cs, { 
    headers : headers 
}).map(res => res.json().items); 

あなたの応答ペイロードに応じました。

小さなメモ:取得リクエストにContent-Typeヘッダーを設定する必要はありません。