I have 2 options in my application. The first checkbox has the name of the Country. I want to update the value of the second value of the selection option with respect to the value selected in the first selection field.
For example, if I select India, then the second value of the selection field should contain all the states of India. Similarly for other countries, but I am not able to do this.
the code:
<select ng-model="selectedCountry" ng-options="item as item for item in country">
<option ng-if="!selectedCountry" value="">Select Country</option>
</select>
<pre>selectedItem: {{selectedItem | json}}</pre>
<select ng-model="selectedState" ng-options="{{selectedState}}">
<option ng-if="!selectedState" value="">Select state</option>
</select>
<pre>selectedItem: {{selectedState | json}}</pre>
JS:
$scope.country = [
"India",
"America",
"Nepal",
"China"
];
$scope.India = ["Bihar"];
$scope.America = ["Arizona"];
$scope.China = ["Beging"];
$scope.Nepal = ["Dhankuta"];
source
share