I'm making a custom component with support for the [(ngModel)] directive, and it works just fine. The problem is that I want to keep a currency format on the view and keep a "normal" number in the model, is this possible for 2-way databinding in Angular 5?
here's the code: https://stackblitz.com/edit/angular-c1qxh4
You will notice some things:
- when loading, everything seems fine, only the view has the format
- when you add let's say 2 more zeros, then the format goes to the model as well (this is what I want to avoid)
- the format in the model is wrong (the commas are not correctly placed, but this is not important, I don't want the format there anyway)
Then, my question would be, is it possible to do that I want to do? If so, what am I doing wrong?
EDIT: For clarification, I don't want to do this on 2 separated components (e.g an input and a label, or an input and an invisible input on top of it (I tried that already)), I want to know if theres a way to do this on a single input.