AngularJS: HTML select to use values from map

angularjs, javascript

Solution

You can use this syntax:

<select ng-model="group" ng-options="key for (key, g) in groups"></select>

You can check out the full documentation for the `select` directive, especially the ngOptions details: http://docs.angularjs.org/api/ng.directive:select

Problem

Have this HTML: ``` <select ng-model="group" ng-options="g.key for g in groups"></select> ``` Although `$scope.groups` is map `{'a':'', 'b':'', 'c':''}` I'd like select to display map keys: a,b,c Currently it selects nothing. How to change `ng-options`?\ UPDATE 1 `g for g in Object.keys(groups)` does not work either.

Original source