Skip to content

Instantly share code, notes, and snippets.

@jsrath
Created January 9, 2019 16:22
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 jsrath/40062c80bb515ea4f41ff3f12198e0ad to your computer and use it in GitHub Desktop.
Save jsrath/40062c80bb515ea4f41ff3f12198e0ad to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'title',
})
export class TitlePipe implements PipeTransform {
transform(title: string): string {
if (title.length > 50) {
title = title.substring(0, 50);
return title.substring(0, title.lastIndexOf(' '));
}
return title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment