0

如何动态设置 ng-dropdown-multiselect 的设置选项,例如设置数据,这可行吗?

在这里查看: http ://plnkr.co/edit/ntVBcGRsD0HXgQoshBlp?p=preview

看法

  <div ng-dropdown-multiselect="" 
  options="example65data" 
  selected-model="example65model" 
  extra-settings="example65settings"></div>

控制器

  $scope.example65model = [{id: 1}]; 
  $scope.example65data = [{id: 1, label: "David"}, {id: 2, label: "Jhon"}]; 
  $scope.example65settings = {selectionLimit: 3};

  $scope.updateMultiSelectLimit = function (){
       $scope.example65settings = {selectionLimit: 2};
   }
  $scope.updateData = function(){
    $scope.example65data = [{id: 1, label: "Peter"}, {id: 2, label: "Yiss"}, {id: 3, label: "Max"}]; 
  }
4

2 回答 2

0

尝试这个

  //HTML
    <div 
      ng-dropdown-multiselect="" 
      options="tabListdata" 
      selected-model="tabListmodel" 
      extra-settings="tabListsettings" 
      events="{ onSelectionChanged: getAllPolicies }"
    >
    </div>

    //JS
        $scope.tabListmodel = [];
        $scope.tabListdata = [{
            id: 1,
            label: "Option 1"
        }, {
            id: 2,
            label: "Option 2"
        }, {
            id: 3,
            label: "Option 3"
        }, {
            id: 4,
            label: "Option 4"
        }, {
            id: 5,
            label: "Option 5"
        }, {
            id: 6,
            label: "Option 6"
        }];

        $scope.tabListsettings = {
            smartButtonMaxItems: 6,
            smartButtonTextConverter: function (itemText, originalItem) {
                return itemText;
            }
        };

        $scope.getAllPolicies = function () {
           console.log("$scope.tabListmodel", $scope.tabListmodel);
        }
于 2018-11-19T10:12:45.583 回答
0
//HTML
<div ng-dropdown-multiselect="example65data" id="xyz"//Can Be Anything  options="example65data" selected-model="example65model"></div>

//JS
$scope.example65model= [];
function abc//Can Be Anything() {
    var allData = hrmsService.getdata//Service Function Call();
    allData.then(function (//Take any variable//pqr) {
        DataObj = [];
        for (var i in pqr.data) {
            item = {}
            item["id"] = pqr.data[i].Id//Primary Key;
            item["label"] = apiSkills.data[i].Description//Any Description Field;
            DataObj.push(item);
        }
        $scope.example65data= DataObj;
    }, function () {
        alert("Data Not Found");
    });
}
于 2017-04-11T08:42:31.713 回答