【发布时间】:2018-06-12 19:51:17
【问题描述】:
我有一个来自 url 的 json 数组: http://blahblahblah.com/company/all,像这样:
在 angularjs 控制器中,我有这样的东西:
$('#example-1').DataTable({
"ajax" : 'http://blahblahblah.com/company/all',
"columns": [
{"data": "companyId"},
{.....}, // I can't assign "data" name to array because it is already unnamed.
]
});
在html table_id example-1中遍历
<table id="example-1" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Company</th>
<th>Legal Name</th>
<th>DBA Name</th>
<th>Formation</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Company</th>
<th>Legal Name</th>
<th>DBA Name</th>
<th>Formation</th>
</tr>
</tfoot>
输出:
所以,我的问题是如何从问题顶部提到的 UNNAMED JSON ARRAY 上方识别列名,并将其显示在 html 表中。等待您的善意回应。
我正在考虑做这样的事情
【问题讨论】:
-
这里有什么问题
-
@JinsPeter 问题是如何在 html 表中显示 json 数组数据,就像在我的情况下只显示“正在加载”
-
过一段时间再回答。现在去吃午饭了。顺便说一句,请不要在 Angular js 控制器中使用 jQuery。使用角度服务
-
@JinsPeter 我正在等待您的友好回复。
标签: javascript jquery angularjs json ajax