RangeError: Maximum call stack size exceeded
66824 просмотра
3 ответа
I guess this means there is a circular reference somehwere but for the life of me I can't guess how to fix it.
Anyone have any ideas?
http://plnkr.co/edit/aNcBcU?p=preview
Check the debug console in Chrome (for example) and you'll see the error. The offending line is
scope.map = map;
scope.map is being "$watched" on the controller via
$scope.$watch("options.map", function (map) { ... }, true);
Автор: thrag
Источник
Размещён: 12.11.2019 09:59
Ответы (3)
18 плюса
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");
}
});
Автор: Roy Daniels
Размещён: 12.04.2013 05:01
9 плюса
I also had this issue and found out that the objects I was comparing had circular references. (Tried JSON.stringify()
which threw 'TypeError: Converting circular structure to JSON').
When I edited my object so that it didn't have circular structure, I fixed this problem and compared objects not by reference but by properties value which was what I needed.
Автор: Marta Размещён: 03.05.2015 02:346 плюса
The third parameter of $watch function tells how to compare the watched object. False to reference comparing only. True to recursive equality comparing, if an object contains circular references, then over maximum stack size. For example:
var a = {ref:b};
var b = {ref:a};
$scope.$watch('b', function(){
//code here will never called, because stack overflow when comparing the object b.
}, true)
Автор: lessisawesome
Размещён: 11.06.2015 02:45
Вопросы из категории :
- angularjs AngularJS с Django - конфликтующие шаблоны тегов
- angularjs Can one AngularJS controller call another?
- angularjs Вставьте HTML в представление
- angularjs Как работает привязка данных в AngularJS?
- angularjs Могу ли я использовать другой префикс вместо `ng` с angularjs?
- angularjs Не удается добраться до $ rootScope
- angularjs Отслеживание просмотров страниц Google Analytics с помощью AngularJS
- angularjs Как сделать пейджинг в AngularJS?
- angularjs Where to put model data and behaviour? [tl; dr; Use Services]
- angularjs Скрытые поля в AngularJs
- angularjs Angularjs - элементы ng-cloak / ng-show мигают
- angularjs angularjs - обновление при нажатии на ссылку с фактическим URL-адресом
- angularjs Как я могу опубликовать данные в виде данных формы вместо полезной нагрузки запроса?
- angularjs Кодировка запроса Angularjs и плохие символы (в FF работают нормально)
- angularjs Как использовать ng-repeat без html-элемента
- angularjs AngularJS - Как использовать $ routeParams при генерации templateUrl?
- angularjs Использование запятой в качестве разделителя списков с помощью AngularJS
- angularjs 'this' vs $ scope в контроллерах AngularJS
- angularjs Как получить параметры URL, используя AngularJS
- angularjs Как вручную запустить отправку формы в AngularJS?