angularjs - Using ng-options on array declared in an object -


in controller, have:

 $scope.sizes = {     things: [         'one',         'two'         ] } 

and in html, have

  <select ng-options="thing thing in sizes.things"></select> 

the resulting combobox has no values. however, in case:

 $scope.things = ['one', 'two'];    <select ng-options="thing thing in things"></select> 

the resulting combobox shows "one", "two" options. can explain why can't access array within $scope object?

you missing ng-model attribute on ng-options select element.

adding ng-model="thing" gets working...

<select ng-model="thing" ng-options="thing thing in sizes.things"></select> 

you can see working example here.

ps not working either array or object. adding ng-model attribute gets both working.


Comments