2016-12-05 4 views
0

OKでオブジェクトを表示する、私はこのangular2

{ "calledCust": { "no": 270, "yes": 9 }, "hasOpened": { "no": 254, "yes": 25 } } 

を持っていると私はビューに表示するために、これをしようとしています。

<ul *ngFor="let profile of profiles.counts"> 
    <li> 
    {{profile | json}} 
    </li> 
</ul> 

それはJSON配列ではないので、角度はちょうど

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. 

を吹くと私は本当に、以下のような結果を表示したいです。

  • calledCust YES:9
  • hasOpened YES:ここ25

感謝

EDIT

は、あなただけに必要な完全なJSON

{ 
    total_rows: 279, 
    bookmark: "g2wAAAABaANkAB5kYmNvcmVAZGI0LnBvcnRlci5jbG91ZGFudC5uZXRsAAAAAmEAYj____9qaAJGQAnZi4AAAABiAAAB7mo", 
    rows: [], 
    counts: { 
     calledCust: { 
      no: 270, 
      yes: 9 
     }, 
     hasOpened: { 
      no: 254, 
      yes: 25 
     } 
    } 
} 
+0

whareはオブジェクト内に 'counts'プロップですか? –

+0

@PankajParkar私は質問を編集しました、ありがとう:) – Jason

答えて

0

ですそれを変換するJSON配列に、のようなもの:

<ul *ngFor="let profile of profiles.counts | convertObjToJsonArray"> 

あなたが反復することができます。

let key; // var key for old JavaScript ES5 
let arr = []; 

key = 'calledCust'; 
arr[0] = obj[key]; 
arr[0].key = key; 

key = 'hasOpened'; 
arr[1] = obj[key]; 
arr[1].key = key; 

は、あなただけだろう、あなたのオブジェクトを取得し、JSON配列にそれをひそかになるパイプを作成するのは簡単だろうこのソリューションをより一般的なものにするためにオブジェクトのプロパティをオーバーライドします。