angularjs-dropdown-multiselect icon indicating copy to clipboard operation
angularjs-dropdown-multiselect copied to clipboard

Usefulness of idProp in selected items array?

Open esco opened this issue 10 years ago • 9 comments

I think the selected items array is better off as an array of id values instead of objects with an "id" property.

// Selected items array
 [
  {
    "id": 2
  },
  {
    "id": 1
  }
]

vs

[2,1]

The idProp doesn't bring any value for most use cases since theres only 1 property on the object and its consistent. We just end up mapping the selected items array into an array of only values.

esco avatar Feb 06 '15 02:02 esco

Agreed. Would it be possible to configure this with a setting?

aortyl avatar Feb 09 '15 19:02 aortyl

If this is a feature that you are still interested in could you please comment. Otherwise I'll close this issue after 2017/02/04

pkempenaers avatar Jan 21 '17 17:01 pkempenaers

+1

esco avatar Jan 22 '17 00:01 esco

👍 still interested something along of the lines of flatten-selected-model: true in settings

mehtadev17 avatar Feb 13 '17 21:02 mehtadev17

💯 also see #102

pablomaurer avatar Feb 17 '17 10:02 pablomaurer

+1 for this feature request

ldeboer avatar May 03 '17 19:05 ldeboer

Has this request been implemented?

edit:

one possible work around to make it work with a REST API is to wrap the requested ids in objects like so:

GET: [1, 2, 3] in $scope: [{id: 1}, {id: 2}, {id: 3}]

$http.get(...) .then(function(data){ $scope.ids = data.ids.map(function(id){ return { id: id }; }; };

when posting the data, you'll have to unwrap the ids:

in $scope: [{id: 1}, {id: 2}, {id: 3}] POST: [1, 2, 3]

$scope.submit = function(){ data = $scope.ids.map(function(idObj){ return idObj.id; }; $http.post(...);

if someone knows a better way, please let me know!

CBrach avatar Jan 25 '18 13:01 CBrach

+1

vovopap avatar Dec 17 '18 13:12 vovopap

a much needed feature

vovopap avatar Dec 17 '18 13:12 vovopap