Skip to content

Instantly share code, notes, and snippets.

@krabello
Created October 19, 2017 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krabello/345e7e2e7f10aec8ae43950408e2b2d4 to your computer and use it in GitHub Desktop.
Save krabello/345e7e2e7f10aec8ae43950408e2b2d4 to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'summary'
})
export class SummaryPipe implements PipeTransform {
transform(value: string, limit?: number) {
if (!value) {
return null;
}
const actualLimit = (limit) ? limit : 100;
return value.substr(0, actualLimit) + '...';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment