This may be a dumb question but I'm very new at Angular. How can I format a float/double to only show two decimals after the separator.
<input type="text" name="whatever" value="{{model.Rate}}" />
I saw some question in SO but I believe that such a basic operation can be done in a simpler way.
Try something like this
<input type="text" name="whatever" value="{{model.Rate.toFixed(2)}} />
assuming Rate is of type number
toFixed() returns a string, and always pads with zeros, so 0.toFixed(2) === "0.00"
Angulars has some built-in filter to do that.
Angular doc
In your case this should be something like this :
value="{{ number_expression | number : 2}}"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With