aboutsummaryrefslogtreecommitdiffstats
path: root/public/projects/angular-small-apps/apps/recipes/src/app/shared/pipes/format-comma.pipe.ts
blob: 761ae16ae5a13636854cb1ac89f41f2cb241613c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { Pipe, PipeTransform } from '@angular/core';

/*
 * Add a space after a comma.
 * Usage:
 *   text | formatComma
 * Example:
 *   {{ foo,bar,baz | formatComma }}
 *   formats to: foo, bar, baz
 */
@Pipe({
  name: 'formatComma',
})
export class FormatCommaPipe implements PipeTransform {
  transform(text: string): string {
    return text.replace(/,/g, ', ');
  }
}