我正在尝试添加一个按钮来为剑道的多选的 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 时,不会向下拉选择占位符添加任何内容。有任何想法吗?