I am trying to implement cascading <select> in angular from some json data.
Basically as soon as user selects a director then the movies dropdown is populated with that directors films.
However I am not sure how to access the set of childitems for a director in the json in the ng-repeat for the movies <select>
The selects are as follows. The first dropdown is populated on load with all director's id and name
<select name="directors" id="directors" ng-model="searchFilter.directorId">
<option ng-repeat="item in directors" value="{{item.id}}">{{item.name}}</option>
</select>
<select name="movies" id="movies" ng-disabled="!searchFilter.movieId" ng-model="searchFilter.movieId">
<option ng-repeat="item in directors.childItems" value="{{item.id}}">{{item.name}}</option>
</select>
The json is
[{
"childItems": [{
"childItems": null,
"id": 3,
"name": "Star Wars"
}
],
"id": 168,
"name": "George Lucas"
}, {
"childItems": [{
"childItems": null,
"id": 10,
"name": "The Hobbit"
}, {
"childItems": null,
"id": 11,
"name": "The Return of the King"
}, {
"childItems": null,
"id": 30,
"name": "Fellowship of the Ring"
}
],
"id": 170,
"name": "Peter Jackson"
}, {
"childItems": [{
"childItems": null,
"id": 3,
"name": "Blade Runner"
}
],
"id": 167,
"name": "Ridley Scott"
}, {
"childItems": [{
"childItems": null,
"id": 3,
"name": "2001 A Space Odyssey"
}
],
"id": 279,
"name": "Stanley Kubrick"
}, {
"childItems": [{
"childItems": null,
"id": 3,
"name": "Manhattan"
}
],
"id": 169,
"name": "Woody Allen"
}
]
Can anybody help?