Skip to content

Instantly share code, notes, and snippets.

@tilmanschweitzer
Last active February 8, 2017 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tilmanschweitzer/83e54338a6ad832d935b to your computer and use it in GitHub Desktop.
Save tilmanschweitzer/83e54338a6ad832d935b to your computer and use it in GitHub Desktop.
function interceptFunction (object, fnName, options) {
var noop = function () {};
var fnToWrap = object[fnName];
var before = options.before || noop;
var after = options.after || noop;
object[fnName] = function () {
before.apply(this, arguments);
var result = fnToWrap.apply(this, arguments);
after.apply(this, arguments);
return result
}
}
var $scope = angular.element(document.querySelector("[ng-app]")).scope();
var Scope = $scope.$root.constructor;
interceptFunction(Scope.prototype, "$digest", {
before: function () {
console.log(this);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment