Created
April 12, 2022 15:13
-
-
Save heiswayi/f24888235b010734470f5885b40c24e1 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: '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