Reputation: 211
i have tree of checkboxes . Departments and under each department there are some checkboxes for employees. when user check on department all employees are selected under this department. I add the unique departments keys to an array. My problem is how to remove the unchecked department key from the array.
$scope.leftdept = function (m) {
console.log(m);
for (i = 0; i < m.length; i++) {
if ($scope.depts.indexOf(m[i].Dep_key) === -1) {
$scope.depts.push(m[i].Dep_key);
}
console.log($scope.depts);
}
Upvotes: 0
Views: 61
Reputation: 723
If you just want to remove the key of object then you can do it this way:
m.forEach(function (dept) {
if(condition) // this is where you check if this department is checked or unchecked
delete dept[Dep_key];
});
Of course this only a vague example, I will need to know your actual object definition to give you a proper answer.
Upvotes: 2