geekchic
geekchic

Reputation: 2441

Kendo UI and AngularJS Multiselect: Difference between ng-model and k-ng-model

I have two Kendo multi-select widgets in my template. The first one is like so:

<select kendo-multi-select="" 
        k-option-label="'Select Programs...'" 
        k-data-text-field="'name'" 
        k-data-value-field="'id'"  
        k-data-source="programs" 
        k-ng-model="selectedPrograms" 
        k-on-change="change(kendoEvent)">
</select>

The second one is like so:

<div ng-repeat="program in userData.programs">

    <select kendo-multi-select="" 
            k-option-label="'Select Services...'" 
            k-data-text-field="'name'" 
            k-data-value-field="'id'" 
            k-data-source="services" 
            ng-model="program.selectedServices" 
            k-on-change="change(kendoEvent)">
    </select>

</div>

Now here is my problem. Initially when I used the attribute to set k-ng-model in both multi-selects, the initial options that I had set in my controller would disappear on clicking the multi-select. This was the same problem as described here. But as the solution there says, I removed the k-ng-model and replaced it with ng-model, and the second multi-select works perfectly.

But when I remove the k-ng-model and replace it with ng-model in my first multi-select, there is no pre-populated data. If I keep the k-ng-model it shows the pre-populated values, but on clicking the multi-select, they disappear.

What's happening here and how do I fix it?

Upvotes: 2

Views: 4848

Answers (2)

Ronak Patel
Ronak Patel

Reputation: 21

ng-model provide only value and you can bind that value to your scope.

For example if you you are using datepicker control of Kendo then it will get you only date value for you like "7/4/2016".

whereas,

k-ng-model provide you complete value as object and you can bind it to your scope.

For example if you are using datepicker control of Kendo then it will get you complete date value for you as object like "2016-07-12T05:00:00.000Z"

You can also refer to this link on Kendo Website @http://docs.telerik.com/kendo-ui/AngularJS/introduction

Upvotes: 2

Petyo Ivanov
Petyo Ivanov

Reputation: 1137

Kendo UI developer here, we have done a lot of back and forth with AngularJS, ng-model, k-ng-model and the multiselect component recently. It would help if you can isolate the problem in a jsbin. Please make sure that you are using the latest version from the repository, too.

Upvotes: 0

Related Questions