Commit 0e0a2bd62ae28cf36df055bbb25cbc25f3642448
Exists in
master
Merge branch 'master' into 'develop'
Master See merge request !7
Showing
1 changed file
Show diff stats
src/js/soloPositivos-directive.js
| File was created | 1 | angular.module('focaDirectivas') | |
| 2 | .directive('soloPositivo', function(){ | ||
| 3 | return { | ||
| 4 | require: 'ngModel', | ||
| 5 | scope: true, | ||
| 6 | link: function(scope, element, attr, ngModel) { | ||
| 7 | ngModel.$parsers.push(function (value) { | ||
| 8 | return '' + value; | ||
| 9 | }); | ||
| 10 | |||
| 11 | if (!ngModel) return; | ||
| 12 | function modificar(texto) { | ||
| 13 | if (texto) { | ||
| 14 | var cambioInput = texto.replace('-', ''); | ||
| 15 | |||
| 16 | if (cambioInput !== texto) { | ||
| 17 | ngModel.$setViewValue(cambioInput); | ||
| 18 | ngModel.$render(); | ||
| 19 | } | ||
| 20 | return cambioInput; | ||
| 21 | } | ||
| 22 | } | ||
| 23 | ngModel.$parsers.push(modificar); | ||
| 24 | } | ||
| 25 | }; | ||
| 26 | }); | ||
| 27 |