angularjs-dropdown-multiselect
angularjs-dropdown-multiselect copied to clipboard
Usefulness of idProp in selected items array?
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.
Agreed. Would it be possible to configure this with a setting?
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
+1
👍 still interested
something along of the lines of flatten-selected-model: true
in settings
💯 also see #102
+1 for this feature request
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!
+1
a much needed feature