A filesize.js pipe for Angular.
-
ngx-filesize
now supports & requires Angular 14+. -
filesize
is now a peer dependency (>= 6.0.0 < 10.0.0
, note10
isn't supported), and so it must be installed alongsidengx-filesize@^3
.
Pipe name was changed from {{ 123 | bytes }}
to {{ 123 | filesize }}
npm install ngx-filesize filesize@9
# or
yarn add ngx-filesize filesize@9
Import the NgxFilesizeModule
into your own NgModule
:
import {NgxFilesizeModule} from 'ngx-filesize';
// ...
@NgModule({
// ...
imports: [
// ...
NgxFilesizeModule,
// ...
]
// ...
})
And use the pipe in your templates:
optionally add options to filesize e.g.
(this would transform 1024 to 1 like for bytes)