JSFiddle - React, Tailwind, and code Playground
by Vamsi krishna mannem
HTML
<script src="https://code.angularjs.org/1.1.5/angular.js"></script>
<body ng-app ng-controller="AppCtrl">
<select ng-model="selectedCountry" ng-options="item as item for item in country">
<option value="">Select Country</option>
</select>
<pre>selectedItem: {{selectedCountry | json}}</pre>
<select ng-model="selectedState" ng-options="item as item for item in state">
<option ng-if="!selectedState" value="">Select state</option>
</select>
<pre>selectedItem: {{selectedState | json}}</pre>
</body>
JavaScript
function AppCtrl($scope) {
$scope.country = ["India", "America", "Nepal","China" ];
var state = {India :["Bihar"],America :["Arizona"],China:["Beging"],Nepal:["Dhankuta"]};
$scope.$watch('selectedCountry', function(newValue, oldValue) {
if ( newValue) {
var country = $scope.selectedCountry;
$scope.state = state[$scope.selectedCountry];
}
});
}