File

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

Description

Replaces all persian numbers in the text to the english numbers.

Example

{{persianTextDigit | enNum}}

Metadata

Name enNum

Methods

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

a string containing one or more non-english digits. Could be an empty string.

Returns : string

input value replaced all persian digits with english digits.

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

/**
 * Replaces all persian numbers in the text to the english numbers.
 * @example {{persianTextDigit | enNum}}
 */
@Pipe({name: 'enNum'})
export class EnNumPipe  implements PipeTransform {

  constructor(private persianNumberService: PersianNumberService) {}

  /**
   * @return input value replaced all persian digits with english digits.
   * @param value a string containing one or more non-english digits. Could be an empty string.
   */
  transform(value: string): string {
    value = String(value);
    return this.persianNumberService.toEnglish(value);
  }
}

result-matching ""

    No results matching ""