所有我使用AngularJS ng-repeat
绑定数据,现在我尝试使用editable-select在AngularJS中实现级联,但是没有任何人帮助如何解决这个问题。
我的要求是我需要两个溺水者,一个是国家,第二个是国家。
当我选择国家/地区下拉列表时,只需要加载那些与国家/地区相关的状态。
如何使用上述所有技术来实现?
此处,我附上jsfiddle
link。
答案 0 :(得分:0)
function CountryCntrl($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']
}
};
}
<div ng-controller="CountryCntrl">
<div>
Country:
<select id="country" ng-model="states" ng-options="country for (country, states) in countries">
<option value=''>Select</option>
</select>
</div>
<div>
States: <select id="state" ng-disabled="!states" ng-model="cities" ng-options="state for (state,city) in states"><option value=''>Select</option></select>
</div>
<div>
City: <select id="city" ng-disabled="!cities || !states" ng-model="city"><option value=''>Select</option> <option ng-repeat="city in cities" value='{{city}}'>{{city}}</option></select>
</div>
</div>
从http://devzone.co.in/simple-example-of-dependable-dropdowns-cascading-dropdowns-using-angularjs/
获取