bryan bryan - 1 year ago 70
AngularJS Question

Changing duplicate $scope array but it's affecting original ng-repeat

I have an ng-repeat that is cycling through


I have the following function:

var copy = $scope.myarray;

$.each(copy, function(index, data){ = "";

When I do this, it seems to be affecting my
loop on

When I do:


They both seem to have the
so I am thinking that is what is screwing things up.

What is the best way to manipulate my copy of the array without affecting the first version?

Answer Source

to copy you should use

var copy = angular.copy($scope.myarray);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download