Reputation: 475
I have the list of customers and the orders for every customer. It looks like this:
<ul>
<li ng-repeat="customer in data.customes" | filter:customerFilterFn ">
{{customer.name}} {{??? total should change depending on nested FILTERED data???}}
<ul>
<li ng-repeat="order in customer.orders" | filter:orderFilterFn ">
{{order.id}} {{order.sum}}
</li>
</ul>
</li>
</ul>
As you see, both lists are filtered by their own functions (for the orders it is a date range).
What is the best approach to get the customer's total for the filtered set of orders?
Upvotes: 0
Views: 31
Reputation: 43
Actually, you can use the same orderFilterFn
for filtering orders before ng-repeat. Something like this: http://codepen.io/anon/pen/xwgYZj
If performance is very important, you can filter orders only once: http://codepen.io/anon/pen/bVgLjB
Upvotes: 1
Reputation: 204
You could use the $index
for the ng-repeat
directive. This way you get each order's value, and then you can maintain a $scope
variable for the customer's total.
Upvotes: 1