File

projects/ngx-persian/src/lib/Pipes/faNum.pipe.ts

Description

Replaces all arabic and english numbers with persian numbers.

Example

{{englishTextDigit | faNum}}

Metadata

Name faNum

Methods

transform
transform(value: string | number)
Parameters :
Name Type Optional Description
value string | number No

a number or string (probably empty).

Returns : string

a string that all english and arabic numbers in the input has been replaced with persian digits.

import { Pipe, PipeTransform} from '@angular/core';
import {PersianNumberService} from '../Services/persian-number.service';

/**
 * Replaces all arabic and english numbers with persian numbers.
 * @example {{englishTextDigit | faNum}}
 */
@Pipe({name: 'faNum'})
export class FaNumPipe implements PipeTransform {

  constructor(private persianNumberService: PersianNumberService) {}

  /**
   *
   * @param value a number or string (probably empty).
   * @return a string that all english and arabic numbers in the input has been replaced with persian digits.
   */
  transform(value: string | number): string {
    value = String(value);
    return this.persianNumberService.toPersian(value);
  }
}

result-matching ""

    No results matching ""