2016-01-22 55 views
-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/

这是设计师给我完成任务表

enter image description here

其中说流量来源,我需要呈现键/值:"name":"Traffic Source #3"它来自每个对象。

有什么建议吗?

编辑

不要关闭这一个,因为我将要关闭最后一个问题,我没有,因为我修改了很多次,这是问题这是一个我需要你帮我来说,其他的太冗长了。抱歉。

+0

@ DanielA.White我只是要求帮助,因为这表的数据不上来,因为我期望的那样。所以,请不要删除我的问题。如果你不想帮忙的话。 – TheUnnamed

+0

你应该转换为数组,使用'Array.map()'创建更好的格式化对象,然后你可以更好地显示你的表。 – ryan0319

+0

你的意思是说你想按特定的顺序显示一组任意的列吗? – Marie

回答

-1

尝试使用AngularJS - 谷歌AngularJS JSON表