Last active
February 8, 2017 13:43
-
-
Save tilmanschweitzer/83e54338a6ad832d935b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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