Reputation: 1183
I'm having an issue trying to loop through an array of objects using ng-options.
html
<select class="select-width" ng-options="type as type.name for type in types">
js
$scope.types = [{name: "Advanced Yield Analysis"},
{name: "Yield by Hybrid"},
{name: "Yield by planting data"},
{name: "Yield by soil type"},
{name: "Yield by management zone"},
{name: "Yield by population/seeding rate"},
{name: "Yield by Treatment"},
{name: "Total Yield by Grower / Location / MC"}];
Here is a JS-fiddle.
Upvotes: 0
Views: 47
Reputation: 4635
You only need to pass the ng-model
. Ng-options will not work when you're not assigning a model.
By default, ngModel watches the model by reference, not value. This is important when binding any input directive to a model that is an object or a collection.
try
<select class="select-width" ng-model="demo" ng-options="type as type.name for type in types"></select>
Upvotes: 1