Would this directive work to suspend watchers while the component is hidden by ng-show
directive("suspendWatchers", function() { return { restrict: 'A', link: function (scope, element, attrs) { scope.$watch(attrs.ngShow, function(newval) { toggleWatchers(scope, false, newval, this);
function toggleWatchers(scope, sibling, pause, keep) { if (pause) { if (scope.watchers_bckp) { scope.$$watchers = scope.watchers_bckp; scope.watchers_bckp= []; } } else { scope.watchers_bckp = scope.$$watchers; scope.$$watchers = []; scope.$$watchers.push(keep); } if (scope.$$childHead) toggleWatchers(scope.$$childHead, true, pause); if (scope.$$nextSibling && sibling) toggleWatchers(scope.$$nextSibling, true, pause); } }) } } })
Would this directive work to suspend watchers while the component is hidden by ng-show
directive("suspendWatchers", function() {
return {
restrict: 'A',
link: function (scope, element, attrs) {
scope.$watch(attrs.ngShow, function(newval) {
toggleWatchers(scope, false, newval, this);