Skip to content

Instantly share code, notes, and snippets.

@designingsean
Created June 30, 2013 15:01
Show Gist options
  • Save designingsean/5895474 to your computer and use it in GitHub Desktop.
Save designingsean/5895474 to your computer and use it in GitHub Desktop.
AngularJS GetFocus directive. If the expression is truthy, then the element receives the focus.
app.directive('ngGetFocus', function() {
return {
restrict: 'A',
link: function(scope, element, attr){
scope.$watch(attr.ngGetFocus, function(value){
if(value)
element.focus();
});
}
};
});
@designingsean
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment