source:
src/Clients/Angular/finki-chattery/src/app/shared-app/pipes/truncate.pipe.ts@
e6a6d9a
Last change on this file since e6a6d9a was e6a6d9a, checked in by , 3 years ago | |
---|---|
|
|
File size: 370 bytes |
Line | |
---|---|
1 | import { Pipe, PipeTransform } from '@angular/core'; |
2 | |
3 | @Pipe({ |
4 | name: 'truncate' |
5 | }) |
6 | export class TruncatePipe implements PipeTransform { |
7 | transform(value: string | null | undefined, limit = 25): string | null { |
8 | if (value) { |
9 | if (value.length <= limit) { |
10 | return value; |
11 | } |
12 | |
13 | return `${value.substr(0, limit)}...`; |
14 | } |
15 | |
16 | return null; |
17 | } |
18 | } |
Note:
See TracBrowser
for help on using the repository browser.