Skip to content

Instantly share code, notes, and snippets.

@c0debreaker
Forked from eliotsykes/ngFocusAndBlur.js
Created July 14, 2014 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c0debreaker/ac0705e545d9a979d368 to your computer and use it in GitHub Desktop.
Save c0debreaker/ac0705e545d9a979d368 to your computer and use it in GitHub Desktop.
app.directive('ngFocus', ['$parse', function($parse) {
return function(scope, element, attr) {
var fn = $parse(attr['ngFocus']);
element.bind('focus', function(event) {
scope.$apply(function() {
fn(scope, {$event:event});
});
});
}
}]);
app.directive('ngBlur', ['$parse', function($parse) {
return function(scope, element, attr) {
var fn = $parse(attr['ngBlur']);
element.bind('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