Last active
August 29, 2015 14:00
-
-
Save ukyo/11364087 to your computer and use it in GitHub Desktop.
zerofill for angular filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div>{{hoge | zerofill:2}}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('foo', []) | |
.filter 'zerofill', -> | |
#これだけあれば足りるだろ的なアレ | |
(n, length) -> "000000000000000000000000000000000#{n}".slice(-Math.max("#{n}".length, length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment