Search code examples
htmlcssangularjsmeanjs

How Do I Multiply Two ng-module Values in Angularjs?


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


Solution

  • 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