Initially, I create a raw array by using the following initialization:
$scope.rawUsers = angular.copy($scope.users);
Subsequently, I make modifications to the data like so:
function filterUsers(searchString, onlyMine) {
$scope.users = [];
_.find($scope.rawUsers, function (itm) {
var groups = [];
if (onlyMine) {
if (!itm.IsMine)
return;
var hasGroup = false;
_.find(itm.Groups, function (group) {
if (lowercaseGroups.indexOf(searchString) != -1) {
hasGroup = true;
groups.push(group);
}
});
if (hasGroup) {
itm.Groups = groups;
$scope.users.push(itm);
}
} else {
if (itm.IsMine)
return;
$scope.users.push(itm);
}
});
}
Is there a way to prevent the loss of the original value in this process?