Set initial value for DropDownList k-ng-model property based on ng-model in AngularJS

0 Answers 30 Views
Juan Manuel
Top achievements
Rank 1
Juan Manuel asked on 25 Feb 2022, 06:42 AM

Hi. I have been struggling with a DropDownList that has an initial value from a controller attached to ng-model property but I cannot make the k-ng-model to be initially set based on the ng-model value.
The datasource is an object array, ng-model corresponds to a numeric value and the k-ng-model is an object selected from the first array.

The only way I could make it working is triggering a change event after dataBound and cascade event (I added a button in the plnkr link in order to do this) or listening to the second cascade event and update the property manually.

I'm including to my plnkr example:

1) Is there a non-hacky or better way to do this? Am I missing something?

2) During the testing, an additional question came up: Why is the cascade event called twice? 

<select kendo-drop-down-list

In my project the initial values come from an API that I can't modify its response, so I only have the key/value and I would like to get description/name at init in order to be used as a label content and validations.

Any help would be really appreciated.

Thank you.

Telerik team
commented on 01 Mar 2022, 02:05 PM

Could you please elaborate a bit more what the issue is? As far as I can see from the provided example, if you pass an object to the k-ng-model, the corresponding item is correctly selected in the DropDownList. Also, I tested the cascading event in this Dojo example using the latest version, and the event only triggers once. Perhaps there was a bug in the version you are using.

No answers yet. Maybe you can help?

Asked by
Juan Manuel
Top achievements
Rank 1
Share this question