.directive('faSuspendable', function () {
return {
link: function (scope) {
// Heads up: this might break is suspend/resume called out of order
// or if watchers are added while suspended
var watchers = [];
scope.$on('suspend', function () {
for (var i = 0, l = scope.$$watchers.length; i < l; i += 1){
watchers.push(scope.$$watchers[i]);
}
scope.$$watchers = [];
});
scope.$on('resume', function () {
while (watchers.length > 0) {
scope.$$watchers.unshift(watchers.pop());
}
});
}
What if...
.directive('faSuspendable', function () {
return {
link: function (scope) {
// Heads up: this might break is suspend/resume called out of order
// or if watchers are added while suspended
var watchers = [];
scope.$on('suspend', function () {
for (var i = 0, l = scope.$$watchers.length; i < l; i += 1){
watchers.push(scope.$$watchers[i]);
}
scope.$$watchers = [];
});
};
})