Commit d19876cc1370d2be9b37bf81b8b08b6300a84fe3
1 parent
3ba8c23621
Exists in
master
and in
1 other branch
linea al final del archivo, sangrías
Showing
1 changed file
with
10 additions
and
11 deletions
Show diff stats
src/js/escKey-directive.js
| 1 | angular.module('focaDirectivas') | 1 | angular.module('focaDirectivas') |
| 2 | .directive('escKey', function () { | 2 | .directive('escKey', function() { |
| 3 | return function (scope, element, attrs) { | 3 | return function(scope, element, attrs) { |
| 4 | element.bind('keydown keypress', function (event) { | 4 | element.bind('keydown keypress', function(event) { |
| 5 | if(event.which === 27) { // 27 = esc key | 5 | if(event.which === 27) { // 27 = esc key |
| 6 | scope.$apply(function (){ | 6 | scope.$apply(function (){ |
| 7 | scope.$eval(attrs.escKey); | 7 | scope.$eval(attrs.escKey); |
| 8 | }); | ||
| 9 | event.preventDefault(); | ||
| 10 | } | ||
| 8 | }); | 11 | }); |
| 9 | |||
| 10 | event.preventDefault(); | ||
| 11 | } |