Cassius
Cassius

Reputation: 153

Angularjs appending templates to each other

how to append code to already existing <div ng-view> container.

like I have template with the following code:

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

then by ajax we loading next date items and so on..so how to make the templates to append in the end, not replace each other and look like:

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

and so on.. ?

thank you in advance.

Upvotes: 0

Views: 154

Answers (1)

callmekatootie
callmekatootie

Reputation: 11228

You need to create a parent ng-repeat as follows:

<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>

Thus, when your server is loading the next date items, simply add the same to invoices array.

Upvotes: 1

Related Questions