I'm trying to create a drop down menu from a simple array in Angular using the ngOptions attribute from angular 1.5, however after reading the docs and browsing the web I can't seem to get it to work with a 'simple' array (with objects it works fine).
I got the following Data
["Interne Vacatures","Human Resources","Sales"]
I use the following code in my view
<select class="form-control" ng-model="widget.GroupNameSearch" id="widgetselectedGroupName" ng-options="group as widget.GroupNameSearch for group in widget.GroupNameSearch | orderBy:'GroupNameSearch' track by widget.GroupNameSearch">
<option value="" disabled selected>--- Kies een group ---</option>
<option value="" ng-if="false"></option>
</select>
However my html creates the following:
I am not sure why it produces these results but if i change my array to a json object I can get it to work. Unfortunetly I don't ant to waste the memory. Below is a working example with JSON:
{"groupName": {
"groupName":"Group 100",
"mail":"Group100@one365dev1.onmicrosoft.com"}
}
<select class="form-control" ng-model="widget.selectedGroupName.groupName" id="widgetselectedGroupName" ng-options="group as group.groupName for group in widget.GroupNameSearch | orderBy:'groupName' track by group.groupName" >
<option value="" disabled selected>--- Kies een group ---</option>
<option value="" ng-if="false"></option>
</select>
Any help would be much appreciated. Cheers!