Skip to content

Instantly share code, notes, and snippets.

@gcpantazis
Created December 20, 2013 04:22
Show Gist options
  • Save gcpantazis/8050383 to your computer and use it in GitHub Desktop.
Save gcpantazis/8050383 to your computer and use it in GitHub Desktop.
Unregistering and re-registering ngBlur.
var noopDirective = function() {
return function() {};
};
module.factory('ngBlurDirective', noopDirective);
module.directive('ngBlur', ['$parse',
function($parse) {
return {
compile: function($element, attr) {
var fn = $parse(attr.ngBlur);
return function(scope, element) {
element.on('blur', function(event) {
scope.$apply(function() {
fn(scope, {
$event: event
});
});
});
};
}
};
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment