I would like to create table with filters in table header. Filter is list of unique values in each column. Here is simplified code:
<table>
<tr>
<th class="dropdown" ng-repeat="field in data.columns">
<span>{{field.title}}</span>
<ul class="dropdown-menu">
<li ng-repeat="item in unique(data.items, field)"><checkbox> {{item.text}}</li>
</ul>
</th>
</tr>
<tr ng-repeat="item in data.items"></tr>
</table>
I use same object array for filter and table but filter create copy of array and remove from copy values that are repeated. And here is my problem.
When I copy array as array.slice(0) deleted values not in filter but in table too (array contains objects). My problem is in references, so I used deepcopy as jQuery.extend(true, [], array) and angular throws error:
[$rootScope:infdig] 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations
My data look like this:
[{id: 1, title: 'AAA', something: [{id: 1, text: "A"}]}, {id: 2, title: 'AAAA', something: [{id: 2, text: "AA"}]}]
Problem is in property something (array.slice(0) donť copy and $.extend copy but angular get error)
Thanks for advices
angular.copy()the angular way. - Jai