hello Experts,
i am new in angularjs i have following JSON data
$scope.countries = {
'India': {
'Maharashtra': ['Pune', 'Mumbai', 'Nagpur', 'Akola'],
'Madhya Pradesh': ['Indore', 'Bhopal', 'Jabalpur'],
'Rajasthan': ['Jaipur', 'Ajmer', 'Jodhpur']
},
'USA': {
'Alabama': ['Montgomery', 'Birmingham'],
'California': ['Sacramento', 'Fremont'],
'Illinois': ['Springfield', 'Chicago']
},
'Australia': {
'New South Wales': ['Sydney'],
'Victoria': ['Melbourne']
}
};
i want only list of country, only list of States
ng-options="country for (country, states) in countries" by using this i got whole JSON data..i want only list of country, only list of States.
please help...thank u

Jithil JohnRank #2,791 · 506 reputationPosted Feb 4, 2016, 1:24 AM EST
$scope.countries = [{ "name": "USA", "id": 1 },{ "name": "Canada", "id": 2 }]; $scope.states = [{ "name": "Alabama", "id": 1, "countryId": 1 }, { "name": "Alaska", "id": 2, "countryId": 1 }, { "name": "Arizona", "id": 3, "countryId": 1 }, { "name": "Alberta", "id": 4, "countryId": 2 }, { "name": "British columbia", "id": 5, "countryId": 2 }]; Select country Select state $scope.updateCountry = function(){ $scope.availableStates = []; angular.forEach($scope.states, function(value){ if(value.countryId == $scope.country.id){ $scope.availableStates.push(value); } }); }