I have an array of objects that I want to modify by removing multiple objects from it.
The following code is currently achieving this successfully, but I'm curious to know if there is a more efficient way to accomplish this task.
This process involves both AngularJS and JavaScript.
Orders
represents the main array on which the operations are carried out.
Order
is an array containing selected items to be removed from the main array Orders
$scope.Order = {};
$scope.removeOrders = function () {
angular.forEach($scope.Order, function (data) {
for (var i = $scope.Orders.length - 1; i >= 0; i--) {
if ($scope.Orders[i].Name == data.Name) {
$scope.Orders.splice(i, 1);
}
}
});
}