All Downloads are FREE. Search and download functionalities are using the official Maven repository.

src.app.shared.pipes.truncate.pipe.ts Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'truncate'
})
export class TruncatePipe implements PipeTransform {

  transform(value: any, args?: any, withTrail = true): any {
    const limit = args ? parseInt(args, 10) : 10;
    let trail = '...';

    if(!withTrail) {
      trail = '';
    }
    return value.length > limit ? value.substring(0, limit) + trail : value;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy