AngularJS - Select value returns "? number:x ?" from scope variable
select
directive is really a bit hard to grok. Here's how it works in conjunction with ng-options
directive (which is amazingly powerful!)
<select
ng-model="filters.teamIdSelected"
ng-options="value.teamId as value.teamName for (key, value) in teams"
></select>
Don't get confused with the values generated in the DOM when inspecting the selects options with dev tools. The value
attribute always gets its index. Corresponding key values pairs still get evaluated against scope, so all you need is to update ´ng-model`.
Hope this helps!
I recommend using ng-options on the select element instead, like so:
<select class="small" ng-model="filters.teamIdSelected" ng-options="team.teamId as team.teamName for team in teams"></select>
Additionally, if you want to include a "Select Team" option:
<select class="small" ng-model="filters.teamIdSelected" ng-options="team.teamId as team.teamName for team in teams">
<option value="">Select Team</options>
</select>