我有一系列这样的对象:
[[null,"SUPPER",7],[1436306400000,"SUPPER",2],[1436220000000,"SUPPER",1],[null,"DINNER",2],[1436133600000,"BREAKFAST",1],[1436133600000,"SUPPER",2],[null,"BREAKFAST",1],[1436392800000,"DINNER",1]]
如何使用ngRepaat写表格行中的每个对象?
答案 0 :(得分:3)
这是一个工作的plunker http://plnkr.co/edit/Fgsrx8VzRfPG7y9seTwQ?p=preview
<table border=1>
<tr ng-repeat="tr in data">
<td ng-repeat="td in tr">{{ td || ' '}}</td>
</tr>
</table>
答案 1 :(得分:2)
将此表分配给范围,然后在模板中使用与此类似的内容:
<!-- Assumes the table you posted is available as "els" on the scope -->
<table>
<tr ng-repeat="e in els">
<!-- In each table cell, use the first, second and third
element from the array you have.
Note: since some of the values are null, I added the
'|| "empty"] to fallback with some message. -->
<td>{{ e[0] || "empty" }}</td>
<td>{{ e[1] || "empty" }}</td>
<td>{{ e[2] || "empty" }}</td>
</tr>
</table>
DEMO:This JSFiddle 有一个工作演示,以及控制器。