Динамически установить параметры настройки для ng-dropdown-multiselect
Как я могу динамически установить параметры настройки для 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"}];
}
2 ответа
//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");
});
}
Попробуй это
//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);
}