Althoug...">

AngularJS: HTML select, use values ​​from map

This HTML has:

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

Although $scope.groupsthere is a map {'a':'', 'b':'', 'c':''} I would like to display the map keys: a, b, c

Currently, he does not choose anything. How to change ng-options? \

UPDATE 1

g for g in Object.keys(groups) doesn't work either.

+4
source share
1 answer

You can use this syntax:

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

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

+11
source

Source: https://habr.com/ru/post/1525869/


All Articles