I have a data display in the view that needs to be formatted first. Previously, I used val.toFixed(2)
which worked fine for numbers, but when letters were included with the numbers, the formatting didn't account for them and only displayed the numbers.
Therefore, I need a solution that can handle both letters and numbers, where only the numbers require formatting like this: 234235.34
.
Below is some of the code snippet I am currently using:
<table>
<tr>
<th ng-repeat='header in headers'>{{header.th}}</th>
</tr>
<tr>
<td ng-repeat='data in headers'>
<div ng-repeat='inner in data.td'>
<span ng-repeat='(prop, val) in inner'>{{val.toFixed(2)}}</span>
</div>
</td>
</tr>
</table>
This functionality is controlled by the following controller:
$scope.LoadMyJson = function() {
// Code logic here
};
You can find a working example on this Fiddle.
Currently, the table is displaying correctly but missing the name
column due to the use of the toFixed
method.
If you have any ideas or suggestions on how to approach this issue, please let me know. Thank you!