I have two select input, first one contain countryName, i want to populate the StateName to the second select input depending on the CountryName that is chosen i.e the stateName for the selected country only.
I bind the countryName from the countryData and the State from State Data but I want the StateData to contain item based on the selected country
<select ng-model="selectedItem.CountryId" class="form-control"
ng-options="item._id as item.CountryName for item in countryData">
<option value="">Select</option>
</select>
<select ng-model="selectedItem.StateId" class="form-control"
ng-options="item._id as item.StateName for item in stateData">
<option value="">Select</option>
</select>
Here is how my stateData looks
[
{
"StateName": "State1",
"CountryName": "Country1",
},
{
"StateName": "State2",
"CountryName": "Country1",
},
{
"StateName": "State3",
"CountryName": "Country2",
},
{
"StateName": "State4",
"CountryName": "Country3",
},
{
"StateName": "State5",
"CountryName": "Country2",
},
{
"StateName": "State6",
"CountryName": "Country3",
}
]