我想知道如何在kendo ui + angular中为下拉列表设置占位符。
目前我有:
模板
<select kendo-drop-down-list ng-model="selectedElement" k-options="options" >
</select>
Controller
...
$scope.options = {
dataTextField: 'label',
dataValueField: 'id',
dataSource: {
data: [
{
"label": "Please Select..."
},
{
"id": "linear",
"label": "Sample Linear"
},
{
"id": "bar",
"label": "Sample Bar"
}
]
}
};
...
如果我用后端调用替换数据源,则那里不能有“请选择”。有解决这个问题的另一种方法吗?
我尝试按照此link中的说明使用 data-option-label =“请选择” ,但是没有运气。
最佳答案
好吧,您可以将其定义为数据属性(more information here)
模板
<select kendo-drop-down-list k-option-label="'item1'" ng-model="selectedElement" k-options="options" >
</select>
或在$ scope中设置optionLabel选项
Controller
...
$scope.options = {
optionLabel: "Item...",
dataTextField: 'label',
dataValueField: 'id',
dataSource: {
data: [
{
"label": "Please Select..."
},
{
"id": "linear",
"label": "Sample Linear"
},
{
"id": "bar",
"label": "Sample Bar"
}
]
}
};
...
关于javascript - Angular + Kendo : Default placeholder for drop down list,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25633065/