简体   繁体   English

json数组转换为表中的字符串

[英]json array converted to string in table

I have an HTML table where I am using AngularJS. 我有一个使用AngularJS的HTML表。 What I am trying to achieve is simply make the array that returns, display as a regular string instead of an array. 我想要实现的只是将返回的数组显示为常规字符串而不是数组。 I also want to make the date display correctly as well. 我也想使日期正确显示。

[{"userId":12,"username":"Smith, Al","date":"2018-03-07T01:00:07.895Z","value":"Pending; CA; good"}]

May be you want something like this: 可能是您想要这样的东西:

<table>
<colgroup>
    <col style="width: 25%">
    <col style="width: 25%">
    <col style="width: 25%">
    <col style="width: 25%">
</colgroup>
<thead>
<tr>
    <th>User Id</th>
    <th>User Name</th>
    <th>Date</th>
    <th>Value</th>
</tr>
</thead>
<tr ng-repeat="obj in jsonArray">
    <td align="middle">{{ obj.userId }}</td>
    <td align="middle">{{ obj.username }}</td>
    <td align="middle">{{ obj.date | date: 'yyyy-MM-dd' }}</td>
    <td align="middle">{{ obj.value }}</td>
</tr>
</table>

https://plnkr.co/edit/b5sya2rzZnGRbakE26iu?p=preview https://plnkr.co/edit/b5sya2rzZnGRbakE26iu?p=preview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM