问题描述
我在没有初始选择值的页面上有一个简单的 angular-kendo ComboBox.它应该显示 placeholder
在那种情况下是文本,但它显示的是 ?未定义:未定义?
I have a simple angular-kendo ComboBox on a page without an initially selected value. It should show the placeholder
text in that case, but instead it's showing ? undefined:undefined ?
HTML
<select kendo-combo-box ng-model="Project" k-options='projectOptions'></select>
JS
app.controller('MyCtrl', function($scope) {
$scope.projectData = [
{name: 'Bob', value: 1},
{name: 'Tom', value: 2}
];
$scope.projectOptions = {
placeholder: "'Select...'",
dataTextField: 'name',
dataValueField: 'value',
dataSource: {
data: $scope.projectData
}
}
});
这是一个显示问题的 plunker.有人能找出原因吗?
Here's a plunker that shows the problem. Can anyone spot the cause?
这曾经在旧版本的 angular-kendo 中有效,但在当前版本中无效.
This used to work in an older version of angular-kendo, but it's not working in the current version.
推荐答案
这和这个问题有点关系:https://github.com/angular/angular.js/issues/1019
This is somewhat related to this issue: https://github.com/angular/angular.js/issues/1019
解决方案很简单:使用 而不是
元素:
The solution is simple: use an <input>
instead of a <select>
element:
<input kendo-combo-box ng-model="Project" k-options='projectOptions'/>
app.controller('MyCtrl', function($scope) {
$scope.projectData = [
{name: 'Bob', value: 1},
{name: 'Tom', value: 2}
];
$scope.projectOptions = {
placeholder: "'Select...'",
dataTextField: 'name',
dataValueField: 'value',
dataSource: {
data: $scope.projectData
}
}
});
(演示)
这篇关于Angular-Kendo ComboBox 占位符文本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!