Aero Wang Aero Wang -4 years ago 93
AngularJS Question

Is there a way to process data inside ng-repeat?

For example, if I have:

<tr ng-repeat="x in lists">
<th style="text-align:right">${{x[2]}}</th>

I would like the
part to be process and turned into format as
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();

Answer Source

You should use number filter to do it.

To format currency as xx.00, use {{ x[2] | number:2 }}

Hope it can help.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download