My title may be long, but I want to explain something:
I am using a service called:
divisionService
This service has a function that returns a list of all Divisions
in my system.
I use this list to populate a select
:
<select class="form-control input-sm" ng-model="search.division.name"
ng-options="item as item.name for item in auoCtrl.divisionList">
<option value="">Alle</option>
</select>
Then I make an HTTP request that selects my users (along with some extra statistics)
$http.get(api.getUrl('getUserStats', null))
.success(function (response) {
auoc.users = response;
});
The response might contain objects like this:
[Object, Object, Object, Object, Object]
Each object looks like this:
object = {
avg_score : 5
completed_modules:
user: object{
division: object{id: 19, location_id: 5, name: "Udvikling", organization_id: 1
},
division_id: 19
id: 1
image_path: "img/profileIcon.png"
}
}
There is a lot of data inside each user object.
Now, I want to bind my select
to sort my list of users by their division
object. I tried using ng-model="search.division"
and then in my repeat loop:
ng-repeat="user in auoCtrl.users | filter: search"
Unfortunately, when I change the value of the select
, everything disappears.
So, my question is, how do I search for the division in this example?