Angular Pipe

Creating an Angular Pipe - Truncate Text

Published on

A common string manipulation operation that I do quite often in Angular templates is to truncating long text to specific length with an ellipsis. From what I’ve found there currently isn’t a truncate pipe built into Angular. The closest thing I’ve found is the SlicePipe which could be used in replacment of this pipe but doesn’t have a suffix option. The code snippet below is my current solution for a truncate pipe with options for length and suffix.