I am getting some data back from my server. The data structure is:
[{"sectorName1": "nameHere",
"subSectors": ["sub1", "sub2", "sub3"]
},
{"sectorName2": "nameHere",
"subSectors": ["sub1", "sub2", "sub3"]
}]
I am trying to display each sectors subSectors with ng-options. So when some uses the dropdown they will see all the subsectors.
I have tried this but doesn't seem to work:
<select id="selectSubSector" class="form-control" name="subSector" ng-model="item" ng-options="sec for sec in mySectors.subSectors ">
</select>
where mySectors is the data that comes back from the server.
Any suggestions?
mySectors? Could it be you wanted to writemySectors[0].subsectors?mySectorsis the data that comes from the server. It contains the objects as shown in the data structure in the question. Those objects then contain a nested subSectors array. And that what I want, that nested subSectors array.mySectors[0].subsectorsif you do not want to aggregate the subsectors of several sectors - which is just a simplemapoperation