Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

Multicheckbow is not working with JSON objects #91

Open
pjchartre opened this issue Mar 9, 2016 · 0 comments
Open

Multicheckbow is not working with JSON objects #91

pjchartre opened this issue Mar 9, 2016 · 0 comments

Comments

@pjchartre
Copy link

Issue similar to #88

I fixed it in

const modelValue = $scope.model[opts.key];
if (angular.isArray(modelValue)) {
const valueProp = to.valueProp || 'value';
angular.forEach(to.options, function(v, index) {
$scope.multiCheckbox.checked[index] = modelValue.indexOf(v[valueProp]) !== -1;
});
}

replacing

$scope.multiCheckbox.checked[index] = modelValue.indexOf(newOptionsValues[index][valueProp]) !== -1;

by

$scope.multiCheckbox.checked[index] = modelValue.map(function(t){return t[valueProp];}).indexOf(newOptionsValues[index][valueProp]) !== -1;

And in the setModel function

function setModel() {
              $scope.model[opts.key] = [];
              angular.forEach($scope.multiCheckbox.checked, function (checkbox, index) {
                if (checkbox) {
                  $scope.model[opts.key].push(to.options[index]);
                }
              });
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@pjchartre and others