directive('input', function() { return { restrict: 'E', link: function(scope, element, attr) { if (attr.type === 'radio' || attr.type === 'checkbox') return; element.bind('blur', function() { scope.$apply(function() { scope.onBlur(element.attr("name")); }); }); } } }); |
In this example, the Controller's "onBlur" callback is called with the element's name. This example returns immediately if the input is of type "radio" or "checkbox", because the "change" event is more applicable for them.
Nice post. For one more useful directive for blur event see this post
ReplyDeletehttp://coding-issues.blogspot.in/2013/10/angularjs-blur-directive.html