Format and Input number on Input text with custom directive

714 Views Asked by At

I am trying to create a directive or pipe that allows me to show formatted an input text as 12.345,67 and too when input numbers with decimal point with enter the decimal comma with comma (,) so 12345,67 not as a period.

Obviously, putting the comma as a decimal gives an error.

Try directive https://stackblitz.com/edit/angular-cf2hz8

Try custom pipe https://stackblitz.com/edit/angular-p3jc14

1

There are 1 best solutions below

0
On

Finaly I find the solution:

I used "Control Value Accessor" of Angular to create my own component use it in this way:

<app-control-value-accessor
     [(value)]="numero"
      required 
      >

https://stackblitz.com/edit/angular-tay52r