这是我的模型:
$scope.orders = [
{
id: 234324,
created: '2015-05-01T13:53:25.366Z',
orderedBy: 'John Smith',
items: [
{
itemNumber: '225-3',
count: 3,
state: 'Sent'
},
{
itemNumber: '3423-1',
count: 1,
state: 'Waiting from supplier'
}
]
},
{
id: 423423,
created: '2015-06-01T13:53:25.366Z',
orderedBy: 'Eva Andersson',
items: [
{
itemNumber: '423-3',
count: 1,
state: 'Sent'
},
{
itemNumber: '234-3',
count: 3,
state: 'Sent'
}
]
}
]
它是一个包含订单的列表,其中每个订单都有一个包含项目的数组。
我想在表中显示。
我尝试做嵌套,ng-repeats
但是事实证明,使用表的静态html语法很困难。我认为我必须以某种方式手动添加子元素。我不确定如何。
JsFiddle:http : //jsfiddle.net/hadey1cf/4/
有任何想法吗?
您可以有多个,tbody
因此很容易做到:
<tbody ng-repeat="order in orders">
<tr class="active">
<td><b>{{order.id}}</b></td>
<td><b>{{order.orderedBy}}</b></td>
<td>{{order.created | date:'yyyy-MM-dd'}}</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr ng-repeat="item in order.items">
<td></td>
<td></td>
<td></td>
<td>{{item.itemNumber}}</td>
<td>{{item.count}}</td>
<td><span class="label label-success label">{{item.state}}</span></td>
</tr>
</tbody>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句