angularjs – ngndo的Kendo MultiSelect更新

前端之家收集整理的这篇文章主要介绍了angularjs – ngndo的Kendo MultiSelect更新前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试添加一个按钮,用于为kendo的多选的ngmodel添加值:

<div ng-controller="MyCtrl">
  <select id='my' kendo-multi-select k-options="selectOptions" k-ng-model="selectedIds"></select>
  <p ng-show="selectedIds.length">Selected: {{ selectedIds }}</p>
  <button ng-click="addSelectedId()">Add selected id</button>
  <input ng-model="enteredId" />
</div>

这是控制器

function MyCtrl($scope) {
      $scope.selectOptions = {
          placeholder: "Select products...",dataTextField: "ProductName",dataValueField: "ProductID",autoBind: false,dataSource: {
              type: "odata",serverFiltering: true,transport: {
                  read: {
                      url: "http://demos.telerik.com/kendo-ui/service/Northwind.svc/Products",}
              }
          }
      };
      $scope.selectedIds = [ 4,7];
       $scope.addSelectedId = function() {
          $scope.selectedIds.push(parseInt($scope.enteredId));
          console.log($scope.selectedIds);
       };
  }

Plunker在这里:

http://plnkr.co/edit/EH0EaMhFsV2JTdwpkqGg?p=preview

添加到selectedIds时,没有任何内容添加到下拉列表选择占位符.有任何想法吗?

解决方法

你需要在你的HTML代码添加k-rebind =“selectedIds”

HTML:

<div ng-controller="MyCtrl">
  <select id='my' kendo-multi-select k-options="selectOptions" k-ng-model="selectedIds" k-rebind="selectedIds"></select>
  <p ng-show="selectedIds.length">Selected: {{ selectedIds }}</p>
  <button ng-click="addSelectedId()">Add selected id</button>
  <input ng-model="enteredId" />
</div>

Please see this updated plunker example

猜你在找的Angularjs相关文章