-2
首先看到的數據,我從後端接收:如何將json對象呈現爲表格?
{
"55f6de98f0a50c25f7be4db0":{
"clicks":{
"total":144,
"real":1
},
"conversions":{
"total":4,
"amount":229
},
"cost":{
"cpc":0.1999999999999995,
"ecpc":1145.0000000000027,
"total":28.79999999999993
},
"revenue":{
"total":4,
"epc":0.027777777777777776
},
"net":{
"roi":-1.1612903225806457,
"total":4
},
"name":"Traffic Source #2",
},
"55f6de98f0a50c25f7be4dbOTHER":{
"clicks":{
"total":144,
"real":1
},
"conversions":{
"total":4,
"amount":229
},
"cost":{
"cpc":0.1999999999999995,
"ecpc":1145.0000000000027,
"total":28.79999999999993
},
"revenue":{
"total":4,
"epc":0.027777777777777776
},
"net":{
"roi":-1.1612903225806457,
"total":4
}
"name":"Traffic Source #3"
},
}
現在的代碼,這個網站是我不想要什麼:
<table>
<tr>
<th>1 header</th>
<th>2 header</th>
<th>3 header</th>
</tr>
<tr ng-repeat="thing in things">
<td>{{thing.asfs}}</td>
<td>{{thing.asx}}</td>
<td>{{person.dsf}}</td>
</tr>
</table>
我想是這樣的
<table>
<tr ng-repeat="head in heads">
{{head}}
</tr>
<tr ng-repeat="bar in bars">
<td ng-repeat="foo in foos">{{foo[bar]}} //or whatever it is</td>
</tr>
</table>
此外,有時候,這個對象會增長,可能會拿出更多的鑰匙,像這樣一個55f6de98f0a50c25f7be4db0
我沒有這個撥弄完全相同的數據我收到所以也許你可以通過在小提琴演奏幫我http://jsfiddle.net/kehaL8av/
這是設計師給我完成任務表
其中說流量來源,我需要呈現鍵/值:"name":"Traffic Source #3"
它來自每個對象。
有什麼建議嗎?
編輯
不要關閉這一個,因爲我將要關閉最後一個問題,我沒有,因爲我修改了很多次,這是問題這是一個我需要你幫我來說,其他的太冗長了。抱歉。
@ DanielA.White我只是要求幫助,因爲這表的數據不上來,因爲我期望的那樣。所以,請不要刪除我的問題。如果你不想幫忙的話。 – TheUnnamed
你應該轉換爲數組,使用'Array.map()'創建更好的格式化對象,然後你可以更好地顯示你的表。 – ryan0319
你的意思是說你想按特定的順序顯示一組任意的列嗎? – Marie