I have an Array of customers.Each customer has an array of Field objects.I would like to filter the Array of customers so I get all the customers that have some specific Field.The customer array looks like that.
[{"id":236,
"username":"Tsakos Ntinidis",
"email":"[email protected]",
"fields":[{"id":2,"name":"Entrepreneurship"},
{"id":16,"name":"Sciences (Math, Physics, Chemistry etc)"},
{"id":3,"name":"Engineering"},
{"id":18,"name":"Journalism"}],
"hasVideo":false,
"profileDescription":null,"isNew":false},
{"id":237,
"username":"Nick Brown",
"email":"[email protected]",
"fields":[{"id":1,"name":"IT"},
{"id":16,"name":"Sciences (Math, Physics, Chemistry etc)"},
{"id":18,"name":"Journalism"}],
"hasVideo":false,
"profileDescription":null}]
and the list that populates the field select field is:
[{"id":1,"name":"Finance"},{"id":2,"name":"Entrepreneurship"},{"id":3,"name":"Engineering"},{"id":4,"name":"Economics"}]
And the html for the customer table is this:
<select ng-model="search.fields.field.id" ng-options="field.id as field.name for field in fields">
</select>
<tr ng-repeat="customer in customers | orderBy:predicate:reverse | filter:search" ng- controller="Controller">
<td class="id">{{customer.id}}</a></td>
<td>{{customer.userName}}</a></td>
</tr>
My main problem is the array is empty after I filter so apparently something goes wrong. Thank you for your help