Can someone help me troubleshoot my second dropdownlist? The first one is working fine but the second one doesn't seem to be functioning correctly.
Here is the HTML code:
<select class="form-control"
ng-options="option as option.label for option in myCtrl.options track by option._id"
ng-model="myCtrl.selected"></select>
<select ng-disabled="!myCtrl.selected" class="form-control">
<option ng-repeat="child in myCtrl.options">@{{child.childs}}</option>
</select>
And here is the JS code:
var vm = this;
vm.options = {};
// Fetching data from "data/support.json" for cascading options
$http.get("data/support.json").success(function(response){
vm.options = response;
vm.selected = vm.options[0];
});
The contents of support.json are shown below:
[{
"_id": "1",
"label": "Title 1",
"childs": [
"Title 1 - sub 1",
"Title 1 - sub 2"
]
},
{
"_id": "2",
"label": "Title 2",
"childs": [
"Title 2 - sub 1",
"Title 2 - sub 2"
]
}]