Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Created December 11, 2013 20:59
Show Gist options
  • Select an option

  • Save PatrickJS/7918376 to your computer and use it in GitHub Desktop.

Select an option

Save PatrickJS/7918376 to your computer and use it in GitHub Desktop.
app.config(function($provide) {
$provide.decorator('$rootScope', function($delegate) {
Object.defineProperty($delegate.constructor.prototype, '$debugMode', {
value: true,
writable: true,
enumerable: false
});
Object.defineProperty($delegate.constructor.prototype, '$toggleDebug', {
value: function(config) {
var scope = this
console.log('before: ', scope.$debugMode)
scope.$debugMode = !scope.$debugMode;
console.log('after: ', scope.$debugMode)
},
enumerable: false
});
return $delegate;
}); // end decorator
}); // end config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment