UI <select kendo-multi-select k-options="selectOptions" k-ng-model="selectedIds"></select>
调节器
$scope.selectOptions = {
placeholder: "Select products...",
dataTextField://cannot understand what to put in here,
valuePrimitive: true,
autoBind: false,
}
我有一个字符串数组如下;
$scope.arrayOfStrings = ["abc", "def", "ghi","jkl"];
我想要这些字符串作为我的选择。
请具体到答案,因为我是棱角分明的新手。提前谢谢。
答案 0 :(得分:0)
您应该使用k-data-source属性指定多选的数据源。在这种情况下,您还应该省略dataTextField:
<div ng-controller="MyCtrl">
<select kendo-multi-select k-options="selectOptions" k-ng-model="selectedIds" k-data-source="arrayOfStrings"></select>
<p ng-show="selectedIds.length" style="padding-top: 1em;">Selected: {{ selectedIds }}</p>
</div>
<script>
angular.module("KendoDemos", [ "kendo.directives" ])
.controller("MyCtrl", function($scope){
$scope.arrayOfStrings = ["abc", "def", "ghi","jkl"];
$scope.selectOptions = {
placeholder: "Select products...",
valuePrimitive: true,
autoBind: false,
};
$scope.selectedIds = [ "abc", "def" ];
})
</script>