Created
March 27, 2015 14:01
-
-
Save shanemgrey/6126ff17cd2f8c8101aa to your computer and use it in GitHub Desktop.
Directive to focus element on page load
This file contains 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
/** | |
* app.autoFocus Module | |
* | |
* Simple directive to focus the element whem DOM ready | |
*/ | |
'use strict'; | |
angular | |
.module('app.autoFocus', []) | |
.directive('autoFocus', function($timeout) { | |
return { | |
restrict: 'A', | |
link: function(_scope, _element) { | |
_element[0].focus(); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment