A filesize.js pipe for Angular
npm install ngx-filesizengx-filesizeA filesize.js pipe for Angular.
ngx-filesize now supports & requires Angular 14+.filesize is now a peer dependency (>= 6.0.0 < 10.0.0, note 10 isn't supported), and so it must be installed alongside ngx-filesize@^3.{{ 123 | bytes }} to {{ 123 | filesize }}``sh`
npm install ngx-filesize filesize@9or
yarn add ngx-filesize filesize@9
Import the NgxFilesizeModule into your own NgModule:`ts
import {NgxFilesizeModule} from 'ngx-filesize';
@NgModule({
// ...
imports: [NgxFilesizeModule]
})
// ...
`
Or, if you don't have an NgModule, in your @Component: `ts
import {NgxFilesizeModule} from 'ngx-filesize';
@Component({
// ...
imports: [NgxFilesizeModule]
})
// ...
`
And use the pipe in your templates:
`handlebars`
{{ 123 | filesize }}
optionally add options to filesize e.g.
`handlebars``
{{ 123 | filesize: {base: 2} }}
(this would transform 1024 to 1 like for bytes)