1

I am using MEAN stack in my application with AngularJS as my front-end. How to multiply to values in table , in table Payment value as with in comma, commission value as in without comma so how to multiply these two values.....My Plunker For Example :-1. Transaction:- payment value is 1,925.10 and commission value is 3 how to multiply comma value and without comma value example:- 1,925.10*3 = 5775.3...

For Example :-2. Trasaction:- payment value is 1,925.10 and commission value is 5 how to multiply comma value and without comma value example:- 1,925.10*5 = 9625.5...

My Html:-

<td >{{mani.payment }}</td>

    <td >{{mani.commission}}</td>

        <td >{{(mani.payment) * (mani.commission)}}</td>

My Data:-

  {
  "_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"
},

I have created Plunker for reference:- Plunker

R. Mani Selvam
  • 320
  • 8
  • 36
  • Related http://stackoverflow.com/a/29507259/1929187 – 0aslam0 Nov 18 '16 at 09:26
  • Please look at my plunker I'M asked how to multiply comma value and without comma value in table....this is not related question, if u knw the solution please update plunker as well to the solution thanks, please help us... – R. Mani Selvam Nov 18 '16 at 09:32

3 Answers3

0

you really should change '1,925.10' to 1925.10 when you respond the request.

1925.10 is the real value, however '1,925.10' is one of its form.

or Make parseFloat convert variables with commas into numbers

function parseFloatIgnoreCommas(number) {
    var numberNoCommas = number.replace(/,/g, '');
    return parseFloat(numberNoCommas);
}
Community
  • 1
  • 1
xiaoyu2er
  • 156
  • 6
0

In your plunker, simply replacing this line:

<td>{{(mani.payment) * (mani.commission)}}</td>

With this other:

<td>{{(mani.payment.replace(',','')) * (mani.commission.replace(',',''))}}</td>

Solves the problem

jcarrenog
  • 199
  • 1
  • 3
0

The number you pass for multiplication isn't a number actualy, It is a string Check your plunkr I have updated it..Or Please Pass it as a number in your JSON.

http://plnkr.co/edit/3zFrSqDWvE5pr3jgKO91?p=preview

 <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>

Or

 $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"
}
   ];