I have two arrays which only contain objects for groups. One contains all the groups on my site. The other contains all the groups a specific user belongs to.
I'd like to subtract: All the groups
- user groups
= groups remaining
I'm using AngularJS, I'm not sure if that helps here or not (maybe a filter could be used).
I looked at previous questions and came across some options:
These are the ones I tried:
$scope.availableGroups = $($scope.groups).not($scope.assignedGroups).get();
$scope.availableGroups = $.grep($scope.groups,function(x) {return $.inArray(x, $scope.assignedGroups) < 0})
This is one of the arrays:
assignedGroups:
[{
id: 115,
name: 'Test Group 2',
Description: '',
owner: 10,
OwnerIsUser: false,
}, {
id: 116,
name: 'Test Group 3',
Description: '',
owner: 71,
OwnerIsUser: false,
}, {
id: 117,
name: 'Test Group 4',
Description: '',
owner: 71,
OwnerIsUser: false,
}, {
id: 118,
name: 'Test Group 5',
Description: '',
owner: 115,
OwnerIsUser: false,
}, {
id: 119,
name: 'Test Group 6',
Description: '',
owner: 8,
OwnerIsUser: true,
}];