Reputation: 99
App demo : http://jsfiddle.net/TR4WC/2/
am I missing something? I looped twice to access the 2nd array
<li ng-repeat="order in orders">
<span ng-repeat="sales in order.sales>
{{sales.salesId}}
</span>
</li>
one extra question : look like I can't do orderBy by salesId in my li because it have access only to the order array.
Upvotes: 0
Views: 81
Reputation: 2135
In the Orders object sales isn't actually an array...it's an object where the key 'salesId' overwrites another 'salesId'.
I've replaced it with the following:
{
'orderId': 1,
'sales': [
{'salesId': 1},
{'salesId': 2}
]
},
{
'orderId': 2,
'sales': [
{'salesId': 3},
{'salesId': 4}
]
}
Upvotes: 1
Reputation: 3012
This is silly but you are missing something, double quotes at the end of order.sales.
<div ng-controller="AppCtrl">
<li ng-repeat="order in orders">
<span ng-repeat="sales in order.sales">
{{sales.salesId}}
</span>
</li>
That works for me.
EDIT: fork of your fiddle http://jsfiddle.net/6eXs6/
Upvotes: 1
Reputation: 399
You can't use the same name 'sales'.
Change:
<li ng-repeat="order in orders">
<span ng-repeat="sale in order.sales">
{{sale.salesId}}
</span>
</li>
Upvotes: 0