How can I use an AngularJS filter to format a number to have leading zeros?

angularjs, javascript

Solution

No filter required, Just use an expression in your html

{{("00000"+1).slice(-6)}}      // '000001'

{{("00000"+123456).slice(-6)}} // '123456'

Problem

I checked the documentation. What I would like is for my numbers to have four digits and leading zeros. ``` 22 to 0022 1 to 0001 ``` Can someone help and tell me if this is possible with the number or another kind of filter?

Original source