nbfontana / ngx-currency

Currency mask module for Angular 📦
https://nbfontana.github.io/ngx-currency
MIT License
237 stars 122 forks source link

formControl value in the Back-end is getting wrong data format #111

Open hazemguent opened 4 years ago

hazemguent commented 4 years ago

The plugin works fine in terms of typing as shown in this example: image

but when implemented with Backend REST methods I get this error: image

when I checked the PUT methods that was sent to Backend using Postman, I found out that this data was sent: image

while it should have been like this: ("." instead of "," and no points for thousands and no weird prefix) image

This is my HTML code:

<input currencyMask #price_per_day formControlName="price_per_day" matInput (change)="changePricePerDay()">

image image

Typescript code that is relevant for formControlName price_per_day under ngOnInit:

       ...
 this.updateForm.get('price_per_day').setValue(this.car.pricePerDay,{ emitEvent: false });

Those are my settings:

"dependencies": {
    "@agm/core": "^1.0.0-beta.5",
    "@angular/animations": "~7.1.0",
    "@angular/cdk": "^7.2.1",
    "@angular/common": "~7.1.0",
    "@angular/compiler": "~7.1.0",
    "@angular/core": "~7.1.0",
    "@angular/forms": "~7.1.0",
    "@angular/http": "^2.1.2",
    "@angular/material": "^7.2.0",
    "@angular/platform-browser": "~7.1.0",
    "@angular/platform-browser-dynamic": "~7.1.0",
    "@angular/pwa": "^0.13.5",
    "@angular/router": "~7.1.0",
    "@angular/service-worker": "~7.1.0",
    "ngx-currency": "^2.5.1"
}
nbfontana commented 4 years ago

Hello @hazemguent, thank you for reporting this.

Can you please do some tests without the (change) event and the matInput directive? In my tests the model updates correctly, so I'm thinking that something within those guys may be the cause of the problem.

I believe that we might have an open issue with the (change) event

hazemguent commented 4 years ago

Hi @nbfontana thanks for answering

but I have tried your suggestions and none of them worked, also removing matInput messed up the whole UI of the page

hazemguent commented 4 years ago

@nbfontana any updates about this bug?