1// $ ng generate pipe pipes/FileSize
2
3//inside src/app/pipes/file-size.pipe.ts
4
5import { Pipe, PipeTransform } from '@angular/core';
6
7@Pipe({
8 name: 'filesize'
9})
10export class FileSizePipe implements PipeTransform {
11 transform(size: number, extension: string = 'MB') {
12 return (size / (1024 * 1024)).toFixed(2) + extension;
13 }
14}