Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leadzero has an infinity loop i.c.w. ngmodelChange and parsefloat #1413

Open
gerwinbouwhuis opened this issue Aug 6, 2024 · 2 comments
Open

Comments

@gerwinbouwhuis
Copy link

Hi there!

Leadzero has an infinity loop when use ngmodelChange and parse to float i.c.w. leadzero="true".
In the added Stackblitz example the first input has an infinity loop
. You can 't change the value.

https://stackblitz.com/edit/angular-i1mfkm?file=src%2Fmain.ts

@andriikamaldinov1
Copy link
Collaborator

@gerwinbouwhuis
Could you clarify the behavior you expect from leadZero when using it with parseFloat?

The infinite loop occurs because leadZero, under the hood, transforms the number 1 into in model 1.00. After that, an additional calculation with parseFloat is performed, which triggers the same transformation again, resulting in the observed behavior.

@gerwinbouwhuis
Copy link
Author

@andriikamaldinov1 leadzero gives a string back maybe is it better to give a number back same as when leadzero is false,
i think leadzero is only for display the number in an input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants