Skip to content

Instantly share code, notes, and snippets.

@marlun78
Last active February 28, 2018 19:19
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save marlun78/28874591822d5aa4216a to your computer and use it in GitHub Desktop.
Save marlun78/28874591822d5aa4216a to your computer and use it in GitHub Desktop.
Angular $rootScope.Scope.$once
/**
* Angular $rootScope.Scope.$once
* Copyright (c) 2014 marlun78
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83
*/
$provide.decorator('$rootScope', function ($delegate) {
var Scope = $delegate.__proto__.constructor;
Scope.prototype.$once = function (name, listener) {
var deregister = this.$on(name, function () {
deregister();
listener.apply(this, arguments);
});
return deregister;
};
return $delegate;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment