我正在使用AngularJS Dropdown Multiselect(http://dotansimha.github.io/angularjs-dropdown-multiselect/#/)
何时使用smartButtonTextConverter它将文本转换为我选择的项目,但当我使用翻译文本更改按钮的默认值时,smartButtonTextConverter停止工作并开始显示1 Checked,2 Checked ...
我的Html代码
WebElement from = driver.findElement(By.id("drag"));
WebElement to = driver.findElement(By.id("drop"));
Actions act = new Actions(driver);
act.clickAndHold(from).build().perform();
Thread.sleep(3000);
act.clickAndHold(to).moveToElement(to).release(to).build().perform();
Thread.sleep(2000);
JS代码:
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<br>
<div ng-dropdown-multiselect="" options="projectData" selected-model="projectModel"
extra-settings="projectsettings" translation-texts="projectText"></div>
</div>
</div>
</div>
</div>
答案 0 :(得分:2)
您需要将smartButtonMaxItems
属性添加到extra-settings
。
$scope.projectsettings = {
smartButtonMaxItems: 3,
smartButtonTextConverter: function(itemText, originalItem) {
return itemText;
},
enableSearch : true,
scrollable : true
};
检查以下代码段
angular
.module('app', ['angularjs-dropdown-multiselect'])
.controller('DefaultController', DefaultController);
DefaultController.$inject = ['$scope'];
function DefaultController($scope) {
$scope.projectModel = [];
$scope.projectData = [{
id: 1,
label: "TMS"
}, {
id: 2,
label: "LMS"
}, {
id: 3,
label: "NLMS"
}];
$scope.projectsettings = {
smartButtonMaxItems: 2,
smartButtonTextConverter: function(itemText, originalItem) {
return itemText;
},
enableSearch: true,
scrollable: true
};
$scope.projectText = {
buttonDefaultText: "Select Project"
};
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://rawgit.com/dotansimha/angularjs-dropdown-multiselect/master/src/angularjs-dropdown-multiselect.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" />
<div ng-app="app">
<div ng-controller="DefaultController">
<div class="container-fluid">
<div class="row">
<div class="col-md-2">
<br>
<div ng-dropdown-multiselect="" options="projectData" selected-model="projectModel" extra-settings="projectsettings" translation-texts="projectText"></div>
</div>
</div>
</div>
</div>
</div>
&#13;