Import
import { WrBytes } from 'ngwr/pipes';
@Component({ imports: [WrBytes] })
export class MyComponent { /* ... */ }Basic usage
{{ 1234 | wrBytes }} <!-- "1.2 KB" -->Decimals
Second argument controls the fraction digits.
{{ 1234567 | wrBytes: 0 }} <!-- "1 MB" -->
{{ 1234567 | wrBytes: 2 }} <!-- "1.18 MB" -->Playground
1.2 MB
{{ 1234567 | wrBytes: 1 }}Customize
Bytes 1234567
Decimals 1
API
| Name | Description | Type | Default |
|---|---|---|---|
wrBytes | Humanise byte counts using binary (1024-based) units. A null / undefined / empty value renders as an empty string, so a nullable field needs no guard around it. | (value: number | string | null | undefined, decimals = 1) => string | — |