RangeError:超出最大调用堆栈大小 [英] RangeError: Maximum call stack size exceeded
本文介绍了RangeError:超出最大调用堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这意味着有一个循环引用,但对于我的生活,我无法猜测如何修复它.
I guess this means there is a circular reference somehwere but for the life of me I can't guess how to fix it.
有人有什么想法吗?
http://plnkr.co/edit/aNcBcU?p=preview
检查 Chrome 中的调试控制台(例如),您会看到错误.违规行是
Check the debug console in Chrome (for example) and you'll see the error. The offending line is
scope.map = map;
scope.map 通过
scope.map is being "$watched" on the controller via
$scope.$watch("options.map", function (map) { ... }, true);
推荐答案
这是因为您比较对象是为了相等而不是为了参考.将您的 $watch
语句更改为:
It's because you're comparing for object for equality rather than for reference. Change your $watch
statement to this:
$scope.$watch("options.map", function (map) {
if (map === undefined) {
alert("map has no value");
} else {
alert("map is defined");
}
});
这篇关于RangeError:超出最大调用堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文