Skip to content

Instantly share code, notes, and snippets.

@jsrath
Created Jan 9, 2019
Embed
What would you like to do?
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