I have an input like the following:
<mat-form-field>
<input matInput type="number" [placeholder]="'Hours' | translate"
formControlName="Work" (blur)="calculate()" />
</mat-form-field>
Right now, the input allows unlimited decimals. I would like to only allow 2 decimals on that input. It could be done with any of the following solutions:
- Restrict the input to 2 decimals, so that I can't insert more
- Allow unlimited decimals and round to 2 decimals when I click another component
Is there any included feature in Angular for doing that? Otherwise, how can I create that restriction/rounding?
Example of the second option:
The user enters the value 1,2582399512
When the input is unfocused, the value is rounded to 1,26