引入文件
‘/select2.css‘, ‘/select2-bootstrap.css‘, ‘/select2.min.js‘, ‘/ui-select2.js‘
html:
<div ui-module="select2"><select ui-select2="{allowClear: true}" ng-model="selectedOrgName" // ng-model class="form-control w-md-important" ng-options="item.orgCode as item.orgName for item in orgNameList" //orgNameList是从接口里取出的数据,item.orgName是显示在option里的内容,item.orgCode就是ng-model的值
ng-change="getInsuranceOrgList()"> //每次点击option调用事件</select></div>
js:
$scope.selectedOrgName = ‘‘; //ng-model的值 $scope.getInsuranceOrgList = function () { var url = ‘/station/org/getInsuranceOrgList‘; var params = { orgName:$scope.selectedOrgName //获取到值 作为入参传给接口 }; $http.post(url,params).success(function(res){ $scope.orgNameList = res.respData.listObj; }).error(function(){}); }; $scope.getInsuranceOrgList();
时间: 2024-10-26 20:34:05