javascript - Issue With Angular $scope.Watch -
i having scope.watch below, in link function of directive
scope.$watch(function () { return scope.chartconfig; }, function (value) { console.log(value); }, true); its trowing below error
angular.js:12221 typeerror: illegal invocation @ isarraylike (angular.js:278) @ foreach (angular.js:332) @ copy (angular.js:913) @ copy (angular.js:879) @ putvalue (angular.js:944) @ copy (angular.js:926) @ copy (angular.js:879) @ putvalue (angular.js:944) @ copy (angular.js:926) @ 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 last 5 iterations: [] http://errors.angularjs.org/1.4.0/$rootscope/infdig?p0=10&p1=%5b%5d @ angular.js:68 @ scope.$digest (angular.js:15594) @ scope.$apply (angular.js:15824) @ angular.js:17580 @ completeoutstandingrequest (angular.js:5370) @ 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 last 5 iterations: [] http://errors.angularjs.org/1.4.0/$rootscope/infdig?p0=10&p1=%5b%5d please find plunker link same
the main problem here error typeerror: illegal invocation.
the object deep watching contains dom elements, angular.copy can't handle.
for example chartconfig.data.datasets[0].controller.chart.chart.canvas reference actual canvas.
furthermore, deep watching such massive object not performance.
add watcher on data need watch.
Comments
Post a Comment