An angularjs directive and corresponding factory to make elements focusable. It's easy!
<div ng-controller="AwesomeCtrl">
<a href="#" ng-click="focusAwesome($event)">Focus on something awesome</a>
<input focus-on="awesome">
</div>
angular.module('yourModule', [
...
'focusOn',
...
]);
...
function AwesomeCtrl($scope, focus) {
$scope.focusAwesome = function($event) {
$event.preventDefault();
focus('awesome');
};
}
- Bower:
bower install ng-focus-on
- npm/browserify:
npm install ng-focus-on
- Download: https://github.com/goodeggs/ng-focus-on/releases/latest
Thanks to this answer from blesh on StackOverflow for inspiration: http://stackoverflow.com/a/18295416/298584
npm install
npm test
MIT.