Commit 74383aee2595420df48f06db648af79232451e28
Exists in
master
and in
1 other branch
Merge branch 'master' into 'master'
Master(efernandez) See merge request modulos-npm/foca-directivas!4
Showing
2 changed files
Show diff stats
package.json
src/js/escKey-directive.js
... | ... | @@ -0,0 +1,13 @@ |
1 | +angular.module('focaDirectivas') | |
2 | + .directive('escKey', function() { | |
3 | + return function(scope, element, attrs) { | |
4 | + element.bind('keydown keypress', function(event) { | |
5 | + if(event.which === 27) { // 27 = esc key | |
6 | + scope.$apply(function (){ | |
7 | + scope.$eval(attrs.escKey); | |
8 | + }); | |
9 | + event.preventDefault(); | |
10 | + } | |
11 | + }); | |
12 | + }; | |
13 | + }); |