Skip to content

Instantly share code, notes, and snippets.

@JonathanDn
Created November 9, 2016 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathanDn/fbc0d78a3603be245e4966e36ce97c2f to your computer and use it in GitHub Desktop.
Save JonathanDn/fbc0d78a3603be245e4966e36ce97c2f to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'maxLength'
})
export class MaxLengthPipe implements PipeTransform {
transform(value: string, limit: number){
if (value.length > limit) return value.substring(0, limit) + '...';
else return value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment