Currently, I am utilizing the MEAN stack for my application with AngularJS as the front-end. I have two tables in which I obtained total sum values like 124.10
in the "conversion rate" column. Now, I am looking to calculate the total sum of the "conversion rate" values by adding them together, such as 124.10 + 124.10 answer = 248.20
... View my Plunker here.
With two tables present, my goal is to compute the total sum of the "conversion rate" values in both tables.
For instance: the first table has a conversion rate of
124.10
, and the second table also has a conversion rate of124.10
. By adding these two values together in a third table, the answer should be248.20
.I have provided a reference in the form of a Plunker here. Any assistance in solving this issue would be greatly appreciated.
My Controller:-
.filter('sumOfValue', function () {
return function (data, key) {
debugger;
if (angular.isUndefined(data) && angular.isUndefined(key))
return 0;
var sum = 0;
angular.forEach(data,function(v,k){
sum = sum + parseFloat(v[key]);
});
return sum.toFixed(2);
}
})
My Data:-
$scope.sryarndebitnote = [
{
"_id": "57ac1b6d82e1c5940ac3c730",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-08-11T06:30:05.118Z",
"shipment_id": "57ac19b982e1c5940ac3c72f",
"conversion_rate": "62.04",
"invoice_value_fob_currency": "Rs",
"invoice_value_fob": "300.231",
"invoice_quantity_unit": "KG",
"invoice_quantity": "37",
"invoice_date": "2016-08-17",
"supplier_name": "Msd",
"buyer_name": "Mani selvam .R"
},
{
"_id": "57b5af69df0475401f644b2e",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-08-18T12:51:53.671Z",
"shipment_id": "57b5af5bdf0475401f644b2d",
"conversion_rate": "62.06",
"exclusive": true,
"invoice_value_fob": "400.343",
"invoice_quantity": "97",
"supplier_name": "Msd",
"buyer_name": "Mani selvam .R"
},]
My Html:-
<tr ng-repeat="mani in resultValue=(sryarndebitnote)">
<td >{{$index + 1}}</td>
<td >{{(resultValue | sumOfValue:'conversion_rate' * 1) + (resultValue | sumOfValue:'conversion_rate' *1)}}</td>
</tr>
<tr>
<td>sum</td>
<td>B = {{resultValue | sumOfValue:'conversion_rate'}}</td>
</tr>
The values in the third table should be calculated by adding A and B, resulting in a final total sum for C, where A + B equals 248.20. Therefore, the total sum for C value should be 496.40.
The total sum for C value should be 496.40.