Skip to content

Instantly share code, notes, and snippets.

@heiswayi
Created April 12, 2022 15:13
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 heiswayi/f24888235b010734470f5885b40c24e1 to your computer and use it in GitHub Desktop.
Save heiswayi/f24888235b010734470f5885b40c24e1 to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'titleLength' })
export class TitleLengthPipe implements PipeTransform {
transform(title: String): String {
if (title === null) {
return '';
} else if (title.length > 15) {
return title.substring(0, 15) + '...';
}
return title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment