File

src/app/@theme/pipes/plural.pipe.ts

Metadata

name ngxPlural

Methods

transform
transform(input: number, label: string, pluralLabel: string)
Parameters :
Name Type Optional Default value
input number no
label string no
pluralLabel string no ''
Returns : string
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`;
  }
}

results matching ""

    No results matching ""