1

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"]; 我希望这些字符串作为我的选择。

请具体回答,因为我是角度新手。提前致谢。

4

1 回答 1

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>

这是一个现场演示:http ://dojo.telerik.com/@korchev/EMaji

于 2015-09-15T12:38:21.223 回答