AngularJS Focused Directive
Angular directive for monitoring when an element has focus.
HTML
<div ng-controller="MyCtrl" form''>
<input type="text" placeholder="Focus me!">
<span tabindex="0">sdsdasd</span>
</div>
JavaScript
var myApp = angular.module( 'myApp', [] );
myApp.controller( 'MyCtrl', [ '$scope', function ( $scope ) {}]);
angular.forEach( [ 'blur', 'focus' ], function ( name ) {
var directiveName = 'myng' + name.replace(/^\w/, function( char ) { return char.toUpperCase(); } );
});
myApp.directive( 'form', [ '$compile', function ( $compile ) {
return function ( scope, element, attr ) {
element.bind("keydown", function(e) {
console.log(e.keyCode)
})
$compile( element )( scope );
};
}]);