I found a helpful example at this link: . It's working well, but I am encountering an issue where I get the object with an index number instead of the expected value.
Here is my controller:
/**
* @ngdoc object
* @name test.Controllers.TestController
* @description TestController
* @requires ng.$scope
*/
angular
.module('test')
.controller('TestController', [
'$scope',
function($scope) {
$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']
}
};
$scope.GetSelectedCountry = function () {
$scope.strCountry = document.getElementById("country").value;
var datas =$scope.strCountry;
console.log(JSON.stringify(datas));
};
$scope.GetSelectedState = function () {
$scope.strState = document.getElementById("state").value;
};
}
]);
On my view page:
Country: Select States:Select City: Select {{city}} Selected Country: {{strCountry}} Selected State: {{strState}} Selected City: {{city}}