Angular + Kendo: Default placeholder for dropdown list

I was wondering how to set the placeholder for the dropdown in kendo ui + angular.

I currently have:

Template

<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" } ] } }; ... 

If I replaced the data source with a backend call, I cannot have "Please select." Is there any other way to solve this problem?

I tried using data-option-label = ". Select the following instructions in this link , but no luck.

+5
source share
1 answer

Well, you can define it as a data strong> attribute ( more info here )

Template

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

or set optionLabel in $ scope

controller

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

...

+8
source

Source: https://habr.com/ru/post/1201677/


All Articles