Commit 25af8f88f60d0e0735fc90d69404ac9f9c8b49d0
1 parent
1452f40f9f
Exists in
master
filtro rellenarDigitos
Showing
1 changed file
with
9 additions
and
0 deletions
Show diff stats
src/js/app.js
| 1 | angular.module('focaFiltros', []) | 1 | angular.module('focaFiltros', []) |
| 2 | .filter('comprobante', function() { | 2 | .filter('comprobante', function() { |
| 3 | return function(valores) { | 3 | return function(valores) { |
| 4 | return (Array(4).join('0') + valores[0]).slice(-4) + '-' + | 4 | return (Array(4).join('0') + valores[0]).slice(-4) + '-' + |
| 5 | (Array(8).join('0') + valores[1]).slice(-8); | 5 | (Array(8).join('0') + valores[1]).slice(-8); |
| 6 | }; | 6 | }; |
| 7 | }) | ||
| 8 | .filter('rellenarDigitos', function() { | ||
| 9 | return function(valor, cantidad) { | ||
| 10 | var ceros = ''; | ||
| 11 | for (var i = 0; i < cantidad; i++) { | ||
| 12 | ceros += '0'; | ||
| 13 | } | ||
| 14 | return (ceros + valor).slice(cantidad * -1); | ||
| 15 | }; | ||
| 7 | }); | 16 | }); |
| 8 | 17 |