Kendo MultiSelect update for ngmodel

I am trying to add a single button to add values ​​to ngmodel from kendo multi select:

<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>

Here is the controller

  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 is here:

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

When added to selectedIds, nothing is added to the select placeholder drop-down list. Any ideas?

+4
source share
1 answer

You need to add k-rebind = "selectedIds" to your html code

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>

See this updated example plunker.

+3
source

All Articles