Question

Inside my $scope i have tobing= 2.00 or tobind=2.20 and i am binding it to

  <span >{{datasource.tobind}}</span>

I want my bound display text to be always "2.00" or "2.20" with the two last digits but the angular seems to be auto rounding it. Its a workaround to set it to text and to bind it as string but will cause a lot places with logic to cast it to number and then to string which is making the bunny cry. Please suggest how to fix auto rounding.

Was it helpful?

Solution

Checkout the number filter or the currency filter.

<span >{{datasource.tobind | number:2}}</span>

or:

<span >{{datasource.tobind | currency}}</span>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top