Ng-zorro-antd: NzInputNumberComponent European number insert

Created on 11 Jul 2019  ·  5Comments  ·  Source: NG-ZORRO/ng-zorro-antd

What problem does this feature solve?

In most European countries, a comma is used to separate the integral part of a number from the decimal part. This means, for example, that three hundred euros and ten cents is written as 300,10 - with a comma as a decimal marker.

It's not possible to insert a number like 10,5 - the value in this case is 105 because the comma is not allowed

What does the proposed API look like?

export class NzInputNumberComponent implements ControlValueAccessor, AfterViewInit, OnChanges, OnInit, OnDestroy {

 onModelChange(value: string): void {
    this.actualValue = this.nzParser(
      value
        .trim()
        .replace(/。/g, '.')
        .replace(/,/g, '.')  <--------------[add this replace]
        .replace(/[^\w\.-] /g, '')
    );
    this.inputElement.nativeElement.value = `${this.actualValue}`;
  }

}


i18n Discussion InputNumber

Most helpful comment

Numbers are even stranger in India.

All 5 comments

@feirer but what is 3,000 means in European countries, should it translate to 3000 or 3.000

@vthinkxie 3,000 means 3 basically (I'm from Italy).

Numbers are even stranger in India.

Hi all, you can override the default nzParser after v9 released

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DoesntWong picture DoesntWong  ·  3Comments

lsbbd picture lsbbd  ·  3Comments

JCqiu picture JCqiu  ·  3Comments

rafaelsmith picture rafaelsmith  ·  3Comments

vthinkxie picture vthinkxie  ·  3Comments