Creating a Custom Pipe in Angular

shorten.pipe.ts

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

@Pipe({
  name: 'shorten'
})
export class ShortenPipe implements PipeTransform {

  transform(value: any): any {
    if (value.length > 10) {
      return value.substr(0, 10) + ' ...';
    }
    return value;
  }
}

References
https://angular.io/guide/pipes#custom-pipes