I have 2 select option box in my app. First select option box contains the name of Countries. I want to update second select option box value with respect to value selected in first select box.
For example, If I select India, than second select box value should contain all states of India. Similar for other countries also but I am not able to do so.
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"];