summaryrefslogtreecommitdiffstats
path: root/webapp/src/app/@theme/pipes/plural.pipe.ts
blob: 4c34096fd5ae52f04378e168b2c11c68e61604bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'ngxPlural' })
export class PluralPipe implements PipeTransform {

  transform(input: number, label: string, pluralLabel: string = ''): string {
    input = input || 0;
    return input === 1
      ? `${input} ${label}`
      : pluralLabel
        ? `${input} ${pluralLabel}`
        : `${input} ${label}s`;
  }
}