Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular.Copy returning RangeError: Maximum call stack size exceeded. How to resolve?

Tags:

angularjs

Is there an upper bound on angular.copy? I have a somewhat complex object that I would like to copy and I am getting the Max call stack error.

like image 659
Eric G Avatar asked Oct 01 '22 16:10

Eric G


1 Answers

it's likely you have circular references inside your own object. Below is an example of a case:

var objectA = {};
var objectB = {};

//circular references
objectA.property = objectB; 
objectB.property = objectA;

$scope.object = {
  propertyA : objectA,
  propertyB: objectB
}

DEMO

like image 115
Khanh TO Avatar answered Oct 05 '22 13:10

Khanh TO