New dashboard look & feel
[src/xds/xds-agent.git] / webapp / src / app / @theme / pipes / plural.pipe.ts
1 import { Pipe, PipeTransform } from '@angular/core';
2
3 @Pipe({ name: 'ngxPlural' })
4 export class PluralPipe implements PipeTransform {
5
6   transform(input: number, label: string, pluralLabel: string = ''): string {
7     input = input || 0;
8     return input === 1
9       ? `${input} ${label}`
10       : pluralLabel
11         ? `${input} ${pluralLabel}`
12         : `${input} ${label}s`;
13   }
14 }