我在我的应用程序中使用MEAN堆栈,将AngularJS作为我的前端。如何将table
Payment value
中的值与comma
中的值相乘,commission
值与不comma
中的值相乘,以便如何将这两个值相乘。 .... My Plunker 例如: - 1。交易: - 付款金额为1,925.10
,佣金价值为3
如何将逗号值与逗号值相乘,例如: - 1,925.10*3 = 5775.3
...
例如: - 2。 Trasaction: - 付款值为1,925.10
,佣金价值为5
如何将逗号值与逗号值相乘,例如: - 1,925.10*5 = 9625.5
...
我的Html: -
<td >{{mani.payment }}</td>
<td >{{mani.commission}}</td>
<td >{{(mani.payment) * (mani.commission)}}</td>
我的数据:
{
"_id": "5816f4fad0be79f809519f98",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-10-31T07:38:34.999Z",
"remarks": "-",
"commission": "3",
"status": "pending",
"amt": "4000",
"cheque_currency": "Rs",
"cheque_value": "300",
"payment": "1,925.10",
"debitnote_no_payment": "3",
"supplier_name": "karikalan",
"buyer_name": "Manidesigns"
},
{
"_id": "5816f4fad0be79f809519f98",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-10-31T07:38:34.999Z",
"remarks": "-",
"commission": "5",
"status": "pending",
"amt": "2000",
"cheque_currency": "Rs",
"cheque_value": "300",
"payment": "1,925.10",
"debitnote_no_payment": "3",
"supplier_name": "karikalan",
"buyer_name": "Manidesigns"
},
我创建了Plunker作为参考: - Plunker
答案 0 :(得分:0)
你真的应该改变&#39; 1,925.10&#39;到1925.10,当你回应请求。
1925.10是真正的价值,然而&#39; 1,925.10&#39;是其形式之一。
或Make parseFloat convert variables with commas into numbers
function parseFloatIgnoreCommas(number) {
var numberNoCommas = number.replace(/,/g, '');
return parseFloat(numberNoCommas);
}
答案 1 :(得分:0)
在您的plunker中,只需更换此行:
<td>{{(mani.payment) * (mani.commission)}}</td>
有了这个:
<td>{{(mani.payment.replace(',','')) * (mani.commission.replace(',',''))}}</td>
解决问题
答案 2 :(得分:0)
你传递的乘法数字不是一个实际的数字,它是一个字符串检查你的plunkr我已经更新了..或者请把它作为你的JSON中的数字传递。
<tr ng-repeat="mani in resultValue=(sryarndebitnote)">
<td >{{$index + 1}}</td>
<td >{{mani.amt}}</td>
<td >{{mani.payment }}</td>
<td >{{mani.commission}}</td>
<td >{{(mani.payment) * (mani.commission)}}</td>
</tr>
<tr>
<td>sum</td>
<td>{{resultValue | sumOfValue:'amt'}}</td>
<td>{{resultValue | sumOfValue:'payment'}}</td>
<td></td>
<td></td>
</tr>
或
$scope.sryarndebitnote = [
{
"_id": "5816f4fad0be79f809519f98",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-10-31T07:38:34.999Z",
"remarks": "-",
"commission": "3",
"status": "pending",
"amt": "4000",
"cheque_currency": "Rs",
"cheque_value": "300",
"payment": 1925.10, // Change to number
"debitnote_no_payment": "3",
"supplier_name": "karikalan",
"buyer_name": "Manidesigns"
},
{
"_id": "5816f4fad0be79f809519f98",
"user": {
"_id": "57400c32bd07906c1308e2cf",
"displayName": "mani selvam"
},
"__v": 0,
"created": "2016-10-31T07:38:34.999Z",
"remarks": "-",
"commission": "5",
"status": "pending",
"amt": "2000",
"cheque_currency": "Rs",
"cheque_value": "300",
"payment": 1925.10,
"debitnote_no_payment": "3",
"supplier_name": "karikalan",
"buyer_name": "Manidesigns"
}
];