angular select2 ng-model 取值 ng-change調用方法


頁面:

 

引入文件

'/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();

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM