加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – ngndo的Kendo MultiSelect更新

发布时间:2020-12-17 17:14:25 所属栏目:安全 来源:网络整理
导读:我正在尝试添加一个按钮,用于为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 bu
我正在尝试添加一个按钮,用于为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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读