Answers for "angular file size pipe"

0

angular file size pipe

// $ ng generate pipe pipes/FileSize

//inside src/app/pipes/file-size.pipe.ts 

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'filesize'
})
export class FileSizePipe implements PipeTransform {
  transform(size: number, extension: string = 'MB') {
    return (size / (1024 * 1024)).toFixed(2) + extension;
  }
}
Posted by: Guest on August-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language