Created
May 3, 2012 18:49
-
-
Save travisjeffery/2588075 to your computer and use it in GitHub Desktop.
Angularjs Focus Directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
angular.directive('tj:focus', function(){ | |
return function(scope, element){ | |
element[0].focus(); | |
}; | |
}); | |
</script> | |
<div> | |
<input type="text" ng:model="model" tj:focus /> | |
</div> |
Cool, updated!
short, sweet and gets the job done
Wow, thank you for this simple solution! Gonna try it out.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems that in the new version the arguments are shifted, so the header for the inner function should be
function(scope, element)