Using an angular array, how do I add and remove elements between two arrays? I $scope.resultsand $scope.listan array of results - results WebAPI call, and I allow the user to select the items that they want to add in the second array. How can I add from the first to the second and remove from the first at the same time?
angular.forEach($scope.results, function (item) {
if (item.selected) {
$scope.list.push(item);
};
});
Also, if I did a second search and tried to add the same element from the first array to my second array (which already had this user), how can I prevent duplicates from being added to the second array (list)?
.
below is a sample of objects that you wanted to pass between arrays. id field is an indicator of uniqueness.