Created
October 19, 2017 02:37
-
-
Save krabello/345e7e2e7f10aec8ae43950408e2b2d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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