import { Pipe , PipeTransform , Component } from '@angular/core' ; @ Pipe ( { name : 'truncate' } ) export class TruncatePipe implements PipeTransform { transform ( value , arg ? ) { if ( value == null ) { return null ; } let limit = parseInt ( arg , 10 ) || 10 ; let trail = '...' ; return value . length > limit ? value . substring ( 0 , limit ) + trail : value ; } }