Reputation: 2084
I'm trying to link two select inputs, so when I change one the other will change based on the selected value in the first select input.
I used ng-options
for that, as following :
first select :
ng-options="region.codeRegion as region.nomRegion for region in regions"
second select :
ng-options="province.codeProvince as province.nomProvince for province in candidature.resident.eps.region.provinces track by province.codeProvince"
for the data I'm using you can find it in the plunker below.
the first select is working but the second didn't work.
Here is a plunker for it : http://plnkr.co/edit/HLCIw099H4UYkGg4s78h?p=preview
How can I solve this ?
Upvotes: 0
Views: 36
Reputation: 1264
You should have ng-model="selectedRegion
on your first select, and on the second select list options based on selectedRegion
.
<select ng-options="region.nomRegion for region in regions" ng-model="selectedRegion"></select>
<select ng-options="province.codeProvince for province in selectedRegion.provinces track by province.codeProvince" ng-model="candidature.resident.eps.province"></select>
Here is the updated plunker
Upvotes: 3