Reputation: 86
Amount : <input type="text" ng-model="amount" />
Within controller:
amount=1000.00
Is there a way where I could display the value in the textbox as
Amount : 1,000.00
and still keep the value in controller as currency/number so that i dont have to parse them into float whenever i need to do some operations.
Upvotes: 1
Views: 1035
Reputation: 9794
use it in the view like this for amount formatting.
<input type="text" ng-model="amount.toLocaleString('en-US', {style: 'currency', currency: 'USD', minimumFractionDigits: 2})"/>
Upvotes: 1