Commit 3ba8c2362144e69f233ec59151dddee779a9daa1
1 parent
ad46708f76
Exists in
master
and in
1 other branch
directiva para tecla escape
Showing
1 changed file
with
14 additions
and
0 deletions
Show diff stats
src/js/escKey-directive.js
... | ... | @@ -0,0 +1,14 @@ |
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 | + | |
10 | + event.preventDefault(); | |
11 | + } | |
12 | + }); | |
13 | + }; | |
14 | + }); | |
0 | 15 | \ No newline at end of file |