yuribsl
yuribsl

Reputation: 171

Angular percentage mask with one decimal

i have searched a lot and i just can't find it. I am using angular and i want a percentage mask with one decimal for an input. So i can write like 0.1, 1.2, 10.2, 99.9%, and stops on 100%. I don't really need the %, the important part is the number mask

Upvotes: 1

Views: 5922

Answers (1)

Giannis
Giannis

Reputation: 1840

I think what you are looking for is that:

{{a | percent:'1.0-1'}}

For an input field:

<input type="text" [ngModel]="a | percent:'1.0-1'" />

Please take a look at the Percent Pipe

and especially the digitsInfo parameter in order to achieve the desired output.

Also find Decimal Pipe if this is what you actually loking for.

Working example

Upvotes: 1

Related Questions