Reputation: 484
Please tell me if this select statement looks wrong to you. For some reason, every selection in the drop-down reads undefined instead of the username.
View
<select class="form-control" ng-model="filteredUserId" ng-options="users.Id as users.Username for user in users"></select>
Controller
dmUser.GetUsers().then((response) =>
{
$scope.users = response.data;
});
I verified in Postman what the results are. They are list of these kinds of objects:
{
"Id": 123,
"FirstName": "john",
"LastName": "smith",
"Username": "johnsmith",
"EmailAddress": "[email protected]"
}
I also tried using the following and it actually works...
<select class="form-control" ng-model="filteredUserId">
<option value="0">All</option>
<option ng-repeat="user in users" value="{{user.Id}}">{{user.Username}}</option>
</select>
It's bugging me that the code using the ngOptions doesn't work. What am I missing?
Upvotes: 1
Views: 23