Reputation: 4167
I have a select option box and it's options (ng-options) are generated from an array within the $scope:
<select ng-model="formData.method" ng-options="method.name for method in methods | orderBy: 'name'"></select>
formData is parsed server-side and the problem I'm having is that the value chosen from the select element gets passed as an object rather than a string. eg: method: { name: 'Shaken' },
I'm pretty new to Angular but am I missing something that will stop this from happening? It should just read method: Shaken,
Upvotes: 1
Views: 166
Reputation: 193291
You need to define ngOptions
as value as label for object in arrayOfObjects
:
ng-options="method.name as method.name for method in methods | orderBy: 'name'"
Upvotes: 2