Angular equals method does not work because of "too much recursion"
I have a graph of javascript objects containing circular references. When I use this object in angular firefox gives me the following error message ("..." contains 100+ duplicates of the same line preceding and following it):
Error: too much recursion equals@http://localhost:8080/ops/bower_components/angular/angular.js:995:1
equals@http://localhost:8080/ops/bower_components/angular/angular.js:997:15
equals@http://localhost:8080/ops/bower_components/angular/angular.js:997:15
...
equals@http://localhost:8080/ops/bower_components/angular/angular.js:997:15
equals@http://localhost:8080/ops/bower_components/angular/angular.js:984:17
equals@http://localhost:8080/ops/bower_components/angular/angular.js:997:15
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:8080/ops/bower_components/angular/angular.js:12491:1
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:8080/ops/bower_components/angular/angular.js:12762:13
done@http://localhost:8080/ops/bower_components/angular/angular.js:8357:34
completeRequest@http://localhost:8080/ops/bower_components/angular/angular.js:8571:7
createHttpBackend/</xhr.onreadystatechange@http://localhost:8080/ops/bower_components/angular/angular.js:8514:1
Is there a way to tell angular to treat objects as equal if they correspond to X levels deeply? Or is angular just not working with circular references?
Backstory (if you want to know)
I have not been able to find a solution in jackson that will not serialize objects that have already appeared on a particular workaround. It sounds like it should be pretty straight forward, but I think the functionality doesn't exist. This is when I came across jsog in this answer that allowed me to pass an object graph (w / circular dependencies) to javascript. I was really glad jsog did it for me, but then I ran into the above error.
source to share
It turns out that angular does not support circular references in the equals method. I forked it, committed a fix, and submitted a pull request. Then I learned that similar fixes had already been considered but rejected due to performance or browser compatibility issues. For my project, I don't care about browser compatibility, so I'll use my own patched version of angular to support circular links.
discussion of pull request here: https://github.com/angular/angular.js/pull/9762#issuecomment-60282505
git fork here: https://github.com/andersonbd1/angular.js
source to share
AngularJs has a good peer-to-peer interface, I suggest taking a look: https://docs.angularjs.org/api/ng/function/angular.equals
angular.equals(o1, o2);
It does deep searches, however I'm not sure if this can be changed Also the performance of angular.equals is described here http://jsperf.com/angular-equals
source to share