Я имею scope.watch, как показано ниже, в моей функции связи директивы
scope.$watch(function() {
return scope.chartConfig;
}, function (value) {
console.log(value);
}, true);
Its trowing ошибки ниже
angular.js:12221 TypeError: Illegal invocation
at isArrayLike (angular.js:278)
at forEach (angular.js:332)
at copy (angular.js:913)
at copy (angular.js:879)
at putValue (angular.js:944)
at copy (angular.js:926)
at copy (angular.js:879)
at putValue (angular.js:944)
at copy (angular.js:926)
at copy (angular.js:879)(anonymous function) @ angular.js:12221(anonymous function) @ angular.js:9055Scope.$digest @ angular.js:15574Scope.$apply @ angular.js:15824(anonymous function) @ angular.js:17580completeOutstandingRequest @ angular.js:5370(anonymous function) @ angular.js:5642
angular.js:12221 Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.0/$rootScope/infdig?p0=10&p1=%5B%5D
at angular.js:68
at Scope.$digest (angular.js:15594)
at Scope.$apply (angular.js:15824)
at angular.js:17580
at completeOutstandingRequest (angular.js:5370)
at angular.js:5642(anonymous function) @ angular.js:12221(anonymous function) @ angular.js:9055Scope.$apply @ angular.js:15826(anonymous function) @ angular.js:17580completeOutstandingRequest @ angular.js:5370(anonymous function) @ angular.js:5642
angular.js:68 Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.4.0/$rootScope/infdig?p0=10&p1=%5B%5D
Пожалуйста, найдите plunker ссылка на то же самое
Угловой обнаруживает эту ситуацию и предотвращает бесконечный цикл, из-за которого браузер становится невосприимчивым. Например, ситуация может возникнуть путем настройки часов на пути и последующего обновления одного и того же пути при изменении значения. Какая потребность в области. $ Смотреть там в этой директиве? –
Yeap Я понял, почему проблема происходит нормально. Но я хочу знать, почему это происходит в вышеупомянутом примере. Мне нужны часы, чтобы перерисовать график, если данные будут изменены. – robin
как ваш код выглядит так: 'scope. $ Watch ('data', function (newVal, oldVal) {/*...*/}, true);' здесь 'true' идиллирует глубокие часы. Так что это требует глубоких наблюдений? или вам нужно только наблюдать за полем данных в файле конфигурации? –