I have been trying to figure out how to use an array if objects as the key values for an ng-select directive
this is the data I want to use
$scope.selec
ng-options
supports both array and object based data source. For example:
Array based data source:
$scope.options = ["Blue", "Red", "Yellow"]
Object based data source:
$scope.options = {
"Blue": "color_1",
"Red": "color_2",
"Green": "color_3"
}
However, you are using an incompatible data structure for the array based option. You can use like this:
and use the selected value as selected.value
. (selected
is bound to one of the objects in the array). This won't work if you want to submit the form via HTTP, so in this case you should convert the options to one of the data structure mentioned above.
I've included these three usage here: http://plnkr.co/IEBQkqJNifY5MZWloDP6
Edit: So I looked at the docs again today and found the way to work with your original data structure.
The plnkr is updated also.