I have a AngularJS method to splice elements from middle of an array but I want to add the elements to be deleted to another array before using splice method.
Here is my code
$scope.method = function (index) {
$scope.array2.push($scope.array1[index]);
$scope.array1.splice(index, 1);
}
when I am calling the method array1[index] values could be retreived but they not getting pushed into array2
here is my html code
<div data-ng-repeat="item in array1">
<button class="btn btn-success pull-right" data-ng-click="method($index)">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
<br />
</div>
splicereturns array or removed elements. Ifarray1is an[]the justarray1.splice(...).forEach(e=>array2.push(e));