JSFiddle - React, Tailwind, and code Playground
by themyth92
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-beta.1/angular.min.js"></script>
<div ng-app="myApp" ng-controller='myCtrl'>
<button id="mybutton" has-focus>the button</button>
<a id="mybutton" href ng-click="doSomething()" has-focus>the anchor</a>
</div>
JavaScript
angular.module('myApp', [])
.controller('myCtrl', function($scope) {
$scope.doSomething = function() {
console.log('it works');
}
})
.directive('hasFocus',function(){
return{
restrict: 'A',
link : function(scope, element, attrs){
element.on('keydown',function(e){
switch(e.which){
case 38 :
e.preventDefault();
console.log('next');
break;
case 40 :
e.preventDefault();
console.log('prev');
break;
}
});
}
}
});