0

I try to limit input number value to 2 decimal places by using decimal pipe.

<input [ngModel]="il.unitPrice | number:'1.2-2'" [ngModelOptions]="{updateOn: 'blur'}" (ngModelChange)="updateAmount($event,i)"                       
class="form-control text-right" type="text" name="unitPrice{{i}}"/>

It works sometimes. But in most cases, the decimal pipe doesn't get fired. for example, when there is no values in the input field, I type '100'. It works. The value is converted to '100.00'. If I change the input '100.00' back to '100'. I expect the value to become '100.00' again, but nothing happened. Another case is '100.0012'. The decimal pipe doesn't get fired either.

Is there anything wrong in above codes? How to use decimal pipe correctly? Thank you very much in advance for your help.

travelinglion
  • 51
  • 1
  • 6

0 Answers0