import { Pipe , PipeTransform } from '@angular/core' ; import { FormatterService } from '@core/formatter.service' ; import { MilesKilometersPipe } from '@shared/miles-kilometers.pipe' ; @ Pipe ( { name : 'sharedDistance' } ) export class DistancePipe implements PipeTransform { constructor ( public formatter ) { } transform ( value , decimals = 0 , empty = this . formatter . empty ) { if ( ! value ) { return empty ; } const milesKilometersPipe = new MilesKilometersPipe ( ) ; return ( this . formatter . number ( value , decimals ) + ' km ' + '(' + this . formatter . number ( milesKilometersPipe . transform ( value , 'tomiles' ) , decimals ) + ' mi)' ) ; } }