我有这个代码在角模板,它只是左侧的标题和右上方的数据。如何使2列与角
<div class="panel-body">
<table class="table table-striped">
<tr ng-repeat="f in fields">
<th>{{ f }}</th>
<td>{{ data[f] }}</td>
</tr>
</table>
</div>
但是,而不是一行中的一个字段,我想有一个行中的2个字段和第二个行中的第三个字段和第四个字段等等。
让我有2列布局
<tr><th>{{ f }}</th>
<td>{{ data[f] }}</td>
<th>{{ f }}</th>
<td>{{ data[f] }}</td>
</tr>
field = ['id', 'name', 'username', 'email', 'age']
data = [{id:1, name: 'john', username: 'john', age: 20, email: 'test'}]
我想要的结果是
<tr><td>id:</td><td>1</td><td>name:</td><td>john</td></tr>
<tr><td>username:</td><td>john</td><td>age:</td><td>20</td></tr>
这应该与NG-重复比较硬编码的东西
你能分享你的'fields'对象? – Vineet
@Vineet'field'是一个列表'['id','name','age','email']' – user3214546
http://stackoverflow.com/questions/18564888/iterate-over-chunks-of-an -array-using-ng-repeat – Vineet