-
-
Save jarbitlira/14efea1d2e98e730f6ab to your computer and use it in GitHub Desktop.
Angular $rootScope.Scope.$once
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
/** | |
* Angular $rootScope.Scope.$once | |
* Copyright (c) 2014 marlun78 | |
* MIT License, https://gist.github.com/marlun78/bd0800cf5e8053ba9f83 | |
*/ | |
$provide.decorator('$rootScope', function ($delegate) { | |
var Scope = Object.create($delegate).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