Skip to content

Instantly share code, notes, and snippets.

@onel0p3z
Created June 19, 2013 15:04
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 onel0p3z/5815022 to your computer and use it in GitHub Desktop.
Save onel0p3z/5815022 to your computer and use it in GitHub Desktop.
Module.directive('ng-blur', function() {
return {
restrict: 'A',
link: function postLink(scope, element, attrs) {
element.bind('blur', function () {
scope.$apply(attrs.ngBlur);
});
}
};
});
And use it in html template:
<input type="text" ng-blur="handleInputBlur()"></input>
And handle it in controller:
$scope.handleInputBlur = function(){
// do some action here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment