Reputation: 9267
For example, if I have:
<tr ng-repeat="x in lists">
<th>{{x[0]}}</th>
<th>{{x[1]}}</th>
<th style="text-align:right">${{x[2]}}</th>
<th>{{x[3]}}</th>
<th>{{x[4]}}</th>
</tr>
I would like the ${{x[2]}}
part to be process and turned into format as xx.00
with function similar to this:
x[2] = x[2].replace(new RegExp("^(\\d{" + (a.length%3?a.length%3:0) + "})(\\d{3})", "g"), "$1 $2").replace(/(\d{3})+?/gi, "$1 ").trim();
Upvotes: 0
Views: 64
Reputation: 2238
You should use number
filter to do it.
To format currency as xx.00
, use {{ x[2] | number:2 }}
Hope it can help.
Upvotes: 3
Reputation: 41
You can use filter for this.
https://docs.angularjs.org/api/ng/filter/filter
https://www.w3schools.com/angular/angular_filters.asp
Upvotes: 1