angular.module('focaDirectivas') .directive('soloPositivo', function(){ return { require: 'ngModel', scope: true, link: function(scope, element, attr, ngModel) { ngModel.$parsers.push(function (value) { return '' + value; }); if(!ngModel) return; function test(texto) { console.log('Texto: ', element); console.log('Valor 2: ',attr); if (texto) { var cambioInput = texto.replace('-',''); if (cambioInput !== texto) { ngModel.$setViewValue(cambioInput); ngModel.$render(); } return cambioInput; } } ngModel.$parsers.push(test); } }; });