Angular + Kendo:下拉列表的默认占位符

时间:2014-09-02 22:00:24

标签: javascript angularjs kendo-ui telerik kendo-dropdown

我想知道如何在kendo ui + angular中为下拉列表设置占位符。

目前我有:

模板

<select kendo-drop-down-list ng-model="selectedElement" k-options="options" >
</select>

控制器

...
$scope.options = {
        dataTextField: 'label',
        dataValueField: 'id',
        dataSource: {
            data: [
                {
                    "label": "Please Select..."
                },
                {
                    "id": "linear",
                    "label": "Sample Linear"
                },
                {
                    "id": "bar",
                    "label": "Sample Bar"
                }
            ]
        }
    };
...

如果我通过后端电话替换数据源,我就不能选择&#39;请选择&#39;那里。还有另一种解决这个问题的方法吗?

我尝试使用 data-option-label =&#34;请按照此link中的说明选择&#34; ,但没有运气。

1 个答案:

答案 0 :(得分:8)

好吧,您可以将其定义为数据属性(more information here

<强>模板

<select kendo-drop-down-list k-option-label="'item1'" ng-model="selectedElement" k-options="options" >
</select>

或在$ scope

中设置optionLabel选项

<强>控制器

...
$scope.options = {
    optionLabel: "Item...",
    dataTextField: 'label',
    dataValueField: 'id',
    dataSource: {
        data: [
            {
                "label": "Please Select..."
            },
            {
                "id": "linear",
                "label": "Sample Linear"
            },
            {
                "id": "bar",
                "label": "Sample Bar"
            }
        ]
    }
};

...

相关问题