From 0ee69c7d9d072d07da1a5c8f60e35a059fb77f88 Mon Sep 17 00:00:00 2001 From: Jose Pinto Date: Fri, 18 Jan 2019 09:32:22 -0300 Subject: [PATCH] aplico uppercaseOnly a todos los input text --- src/js/uppercaseOnly-directive.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/js/uppercaseOnly-directive.js b/src/js/uppercaseOnly-directive.js index ee07dd5..c4bca73 100644 --- a/src/js/uppercaseOnly-directive.js +++ b/src/js/uppercaseOnly-directive.js @@ -1,9 +1,9 @@ angular.module('focaDirectivas') - .directive('uppercaseOnly', [ + .directive('input', [ function() { return { - restrict: 'A', - require: 'ngModel', + restrict: 'E', + require: '?ngModel', link: function(scope, element, attrs, ctrl) { function parser(value) { @@ -19,14 +19,17 @@ angular.module('focaDirectivas') } function formatter(value) { - if (ctrl.$isEmpty(value)) { + if (ctrl.$isEmpty(value) || typeof value !== 'string') { return value; } return value.toUpperCase(); } - ctrl.$formatters.push(formatter); - ctrl.$parsers.push(parser); + if(attrs.type === 'text') { + + ctrl.$formatters.push(formatter); + ctrl.$parsers.push(parser); + } } }; } -- 1.9.1