angular file size pipe

Solutions on MaxInterview for angular file size pipe by the best coders in the world

showing results for - "angular file size pipe"
Jessica
16 Oct 2017
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}