gpt4 book ai didi

angularjs - Kendo DropdownList 和 ng-model 不起作用

转载 作者:行者123 更新时间:2023-12-02 06:54:11 27 4
gpt4 key购买 nike

我有一个绑定(bind)到 ObservableArray/DataSource 的 Kendo 下拉列表。它适本地填充数组中的值。但是当我将 ng-model 绑定(bind)到属性时,下拉列表无法选择值。

HTML:

<select kendo-drop-down-list k-options="dropOptions" ng-model="user.id"></select>

JS:

var users = [
{ id: 1, name: 'A' },
{ id: 2, name: 'B' },
{ id: 3, name: 'C' },
{ id: 4, name: 'D' },
{ id: 5, name: 'E' },
{ id: 6, name: 'F' }
];

var usersDataSource = new kendo.data.ObservableArray(users);

$scope.dropOptions = {
dataSource: usersDataSource,
dataTextField: 'name',
dataValueField: 'id',
optionLabel: "Select one..."
};

$scope.welcome = "World";
$scope.user = { id: 3 }

$scope.user = { id: 3 } 应该强制下拉列表选择 C。

这是 Plunkr 的链接: http://plnkr.co/edit/BxTqWet5sz725ZtKEKJr?p=preview

我如何让下拉列表根据在与 ng-model 绑定(bind)的属性中分配的值进行选择。我也使用过 k-ng-model,但它不起作用。请帮助我我在这里做错了什么。谢谢。

编辑:下拉列表中的选择不是硬编码的。它将从数据库中获取。

最佳答案

我在 Kendo v2015.3.1111 中使用 Angular 1.4.9。降级到 Angular 1.4.8 使其工作。

关于angularjs - Kendo DropdownList 和 ng-model 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35192985/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com