dotansimha / angularjs-dropdown-multiselect

AngularJS Dropdown Multiselect
http://dotansimha.github.io/angularjs-dropdown-multiselect/
MIT License
441 stars 454 forks source link

selected model doesn't reflect the options objects #365

Open Planet910 opened 7 years ago

Planet910 commented 7 years ago

In the example in the doc when you select an item from the dropdown the selected-model array is filled with the corresponding object inside the options array but when I use it in the selected-model array is inserted an object with only the id property. I need the full object (also with the label property) to be inserted in the selected-model, is there a way to do it?

Selected Model: [{"id":"AL"},{"id":"AK"}]

options:

$scope.example14data = [{
        "label": "Alabama",
            "id": "AL"
    }, {
        "label": "Alaska",
            "id": "AK"
    }, {
        "label": "American Samoa",
            "id": "AS"
    }, {
        "label": "Arizona",
            "id": "AZ"
    }, {
        "label": "Arkansas",
            "id": "AR"
    }]
Makanz commented 7 years ago

I have the same problem in my project.

GiuliaBusnelli commented 7 years ago

Me too

m3shark commented 7 years ago

Copying both the label and the id into the selected model appears to be the default behavior in the new versions of 2.0 beta.

If you are using version 1.x I was able to successfully force this behavior by setting externalIdProp to an empty string (aka { externalIdProp : '' } ) in extra-settings.