【发布时间】:2014-10-22 20:49:55
【问题描述】:
我有一个包含循环引用的 javascript 对象图。当我在 Angular 中使用这个对象时,firefox 会给我以下错误消息(“...”包含 100 多个重复的前后同一行):
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
如果它们匹配 X 层深度,有没有办法告诉 Angular 认为对象相等?还是 angular 不适用于循环引用?
背景故事(如果您想知道)
我无法在 jackson 中找到一个解决方案,该解决方案不会序列化已经出现在特定遍历路径上的对象。这似乎对我来说应该很简单,但我猜该功能不存在。就在那时,我偶然发现了 this answer 中的 jsog,它使我能够将我的对象图(带循环依赖项)转移到 javascript。很高兴jsog为我做了这件事,但是后来我遇到了上面的错误。
【问题讨论】:
标签: javascript angularjs jsog