primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Spinner precision not working

Open KevinHtzl opened this issue 6 years ago • 6 comments

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports) https://stackblitz.com/edit/angular-ivy-ps8kdq

Current behavior The precision attribute is not working as expected. In the example i set [precision]="2" and expected 2 digits in the decimal section. But i can type as much as i want and it is not formated.

Expected behavior If there are more digits in the decimal section than precision allows, it should be formated on blur.

Minimal reproduction of the problem with instructions simple, just add [precision]="2" and [formatInput]="true" to a spinner component. and type in more than 2 digits in the decimal section https://stackblitz.com/edit/angular-ivy-ps8kdq

Please tell us about your environment: Windows, local environment

  • Angular version: 5.X 9.1.4

  • PrimeNG version: 5.X 9.1.0

  • Browser: all

  • Language: [all ]

KevinHtzl avatar May 27 '20 06:05 KevinHtzl

Hi, I encountered the same problem with spinner. But if you're using primeng 9.1.0 you could try the new InputNumber-Component which supports Min-Max Fraction Digits. I tested it on the showcase site - it seems to work. Unfortunately I cannot use v9.1.0, I tried updating but I got some node_module errors when serving the app. I'm still trying to get it to work.

hope I could help you.

thimma11 avatar May 27 '20 14:05 thimma11

Great, thank you! I have not read the update notes yet. This is a realy cool feature, i have modified the spinner component to use it as currency input, but there is no need to do this anymore.

KevinHtzl avatar May 27 '20 14:05 KevinHtzl

Glad I could help you. Would you mind telling me how you modified the spinner for currency? I need to do the same since I cannot update my project to 9.1.0 at the moment...

thimma11 avatar May 27 '20 14:05 thimma11

I have hidden the controls and displayed a currency symbol in place. The formatting is still done by the p-spinner. This is my code. Just need some css code to hide the buttons and move the currency symbol.

<div class="currency-input">
       <p-spinner class="number-input" inputStyleClass="form-control"
         [(ngModel)]="setting.flags.tatsaechlicheKgAusgabenWert" [step]="0.25" [formatInput]="true"
         thousandSeparator="." decimalSeparator="," placeholder="Tatsächliche Krankengeldausgaben">
</p-spinner>
<span class="currency">€</span>
</div>

KevinHtzl avatar May 27 '20 14:05 KevinHtzl

Dankeschön ;) Grüße aus Österreich

thimma11 avatar May 27 '20 14:05 thimma11

Hi,

You can use inputNumber component and give us the feedback to improve it.

Best Regards,

mertsincan avatar Sep 01 '20 11:09 mertsincan