在html中
<select class="form-control"
。。。
data-ng-init="dropdownDataType14.initSource('9321')"
ng-options="row.text as row.text for row in dropdownDataType14.dropdown_select"
ng-selected="row.text==enterpriseinfo.enterprisetype"
class="selectpicker form-control"
ng-change="chooseUnitbindingCity(enterpriseinfo.belongcity)"
emptyText="---请选择---"
style="font-size: 15px" required>
在js中加上数据字典的引入
$scope.dropdownDataType14 = {
simple : true,
dropdown_select : [],
dropdown_onchange : function(selected) {
console.log(selected);
},
sourceCallBack : function(target, data) {
target.dropdown_select = topcheer.toDoubleDropdownArray(data,
'value', 'code');
},
initSource : function(code) {
dropdownSourceService.initDropdownParamsSource(this, code,
this.sourceCallBack);
}
};
需要注意的是 一级数据字典用 dropdownDataType14.dropdown_select
ng-options="row.text as row.text for row in dropdownDataType14.dropdown_select"
不要用 belongCityDrops (存在读不出来的情况)
html中:
ng-options="row.text as row.text for row in belongCityDrops"
js中:
$scope.dropdownDataType14.initSource("9321");
$scope.belongCityDrops = $scope.dropdownDataType14.dropdown_select;
关于二级树
<select class="form-control" data-toggle="popover"
data-ng-init="dropdownDataType15.initSource('1009')"
ng-options="row.text as row.text for row in countryDropdownTar"
ng-selected="row.text==enterpriseinfo.belongcountry"
ng-change="chooseUnitbindingCountry(enterpriseinfo.belongcountry)"
name="text" class="selectpicker form-control"
emptyText="---请选择---">
<option value="" selected="selected">
countryDropdownTar中放的是一级树对应内容
// 市与县的级联
$scope.countryDropdownTar = [];
$scope.chooseUnitbindingCity = function(obj) {
if ($scope.countryDropdownTar)
$scope.countryDropdownTar.splice(0,
$scope.countryDropdownTar.length);
zxDropdownSrc = $scope.dropdownDataType15.dropdown_select;
if (obj == "银川市") {
for (var i = 0; i < zxDropdownSrc.length; i++) {
if (zxDropdownSrc[i].code.substring(0, 4) == "3301") {
$scope.countryDropdownTar.push(zxDropdownSrc[i]);
}
}
} else if (obj == "石嘴山市") {
for (var i = 0; i < zxDropdownSrc.length; i++) {
if (zxDropdownSrc[i].code.substring(0, 4) == "3302") {
$scope.countryDropdownTar.push(zxDropdownSrc[i]);
}
}
} else if (obj == "吴忠市") {
for (var i = 0; i < zxDropdownSrc.length; i++) {
if (zxDropdownSrc[i].code.substring(0, 4) == "3303") {
$scope.countryDropdownTar.push(zxDropdownSrc[i]);
}
}
} else if (obj == "固原市") {
for (var i = 0; i < zxDropdownSrc.length; i++) {
if (zxDropdownSrc[i].code.substring(0, 4) == "3304") {
$scope.countryDropdownTar.push(zxDropdownSrc[i]);
}
}
} else if (obj == "中卫市") {
for (var i = 0; i < zxDropdownSrc.length; i++) {
if (zxDropdownSrc[i].code.substring(0, 4) == "3305") {
$scope.countryDropdownTar.push(zxDropdownSrc[i]);
}
}
}
}