import { Component } from '@angular/core';
import { WrBytes } from 'ngwr/pipes';
@Component({ imports: [WrBytes] })
export class MyComponent {}wrBytes
Show a byte count as kB, MB or GB.
Installation
Import the class. This entry point has no stylesheet.
Basic usage
{{ 1234 | wrBytes }} <!-- "1.2 kB" -->Decimals
The second argument sets the decimals.
{{ 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 | Formats bytes in 1024-based units. null, undefined and empty render as an empty string. | (value: number | string | null | undefined, decimals = 1) => string | — |