a8m / a8m/angular-filter

Add filter "zero padding"

Đang mở
#80 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
2.9k
Fork
319
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Another filter I found useful is the zero padding. Would you mind to add it in the library also? Thanks.

```
String.prototype.repeat = function( num ) {
return new Array( num + 1 ).join( this );
}

app.filter('zeroPadding', function () {
return function(input, n) {
if(input === undefined)
input = "";
if(input.length >= n)
return input;
var zeros = "0".repeat(n);
return (zeros + input).slice(-1 * n);
};
});
```

Here is a reference:
https://gist.github.com/njouanin/3348ed708d527de8641c

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.