Skip to content

Instantly share code, notes, and snippets.

@shanemgrey
Created March 27, 2015 14:01
Show Gist options
  • Save shanemgrey/6126ff17cd2f8c8101aa to your computer and use it in GitHub Desktop.
Save shanemgrey/6126ff17cd2f8c8101aa to your computer and use it in GitHub Desktop.
Directive to focus element on page load
/**
* 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