0

如何将代码附加到现有<div ng-view>容器。

就像我有带有以下代码的模板:

<p>{{date}}</p>
<div ng-repeat='i in items'>
    <span>{{i.created}}</span>
    <span>{{i.order}}</span>
    <span>{{i.customer}}</span>
</div>

然后通过ajax我们加载下一个日期项目等等..所以如何使模板最后附加,而不是相互替换,看起来像:

2013-05-03

created
order
customer

created
order
customer

created
order
customer

2013-05-04

created
order
customer

2013-05-05

created
order
customer

created
order
customer

等等.. ?

先感谢您。

4

1 回答 1

1

ng-repeat您需要按如下方式创建父级:

<div ng-repeat="entry in invoices">
    <p>{{entry.date}}</p>
    <div ng-repeat='i in entry.items'>
        <span>{{i.created}}</span>
        <span>{{i.order}}</span>
        <span>{{i.customer}}</span>
    </div>
</div>

因此,当您的服务器正在加载下一个日期项目时,只需将其添加到 invoices 数组即可。

于 2013-05-03T10:28:03.037 回答