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
... | ... | @@ -4,4 +4,13 @@ angular.module('focaFiltros', []) |
4 | 4 | return (Array(4).join('0') + valores[0]).slice(-4) + '-' + |
5 | 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 | }); |