JsDaddy / ngx-mask

Angular Plugin to make masks on form fields and html elements.
https://jsdaddy.github.io/ngx-mask
MIT License
1.15k stars 298 forks source link

Apply mask on initial load of component #1291

Closed tnfoundry closed 6 months ago

tnfoundry commented 10 months ago

🚀 feature request

Description

Apply mask on initial load. If value is 100, then render as 100.00

Describe the solution you'd like

Mask is applied when value is set on model. When loading component, a reactive form with an amount control exists and value is set to 100. It would be really helpful if when that component rendered that its value was formatted as 100.00

Describe alternatives you've considered

Currently, we have to use a small service to format the value to 100.00 on initial load and it would be great if that service was not required to apply the initial mask.

andriikamaldinov1 commented 6 months ago

@tnfoundry Hi. What mask you using for this ??

tnfoundry commented 6 months ago

Currency. Ex. On an edit page, I was attempting to load data into an input for a US currency field. It would be great if it the model data contained 100 and formatted as 100.00 (currency).

andriikamaldinov1 commented 6 months ago

@tnfoundry If I understand correctly you need this - https://stackblitz.com/edit/stackblitz-starters-smhywb?file=src%2Fmain.ts

andriikamaldinov1 commented 6 months ago

@tnfoundry if you have new question. Create new issue by teamplate