I'm developing an application using Laravel
and AngularJS
. I've always found it difficult to format a number to fill in with zeros in Javascript, so I opted to use Laravel to bring me the number of the id
field already formatted with the zero fill.
But now I would like to do AngularJS, since I realized that the components of it (or even the ones that are created) can be highly reused.
What is the step for me to create a function to format the values displayed in view
by filling leading zeros in Angular?
Is there a function for this already or do I need to create one? How to proceed?
For example:
<tr ng-repeat="u in usuarios">
<td ng-bind="usuario.id|preencher_com_quatro_zeros_a_esquerda"></td>
<td ng-bind="usuario.nome"></td>
</tr>
In the example I need to preencher_com_quatro_zeros_a_esquerda
return a number formatted with 4 leading zeros. How to do?