0

In my shopping cart app i am getting offers in price and percentage from server. I need to differentiate the price value and percentage values with Rs. and %.

Here is my code in controller:

if(result.type == 'Price'){                                     
                                    $scope.invoice_amt = $scope.invoice_amt - result.offer ;                                                                                    
                                    } 
                                    else if(result.type == 'Percentage'){                                     
                                    $scope.invoice_amt = $scope.invoice_amt * result.offer/100;                                                                                    
                                    } 

I am getting the value in HTML as {{invoice_amt}} How to show the offers in rs. and percentage.

Vignesh
  • 35
  • 1
  • 8

1 Answers1

0

You have to use currency filter, this below sample will print in Rupees ( ₹ )

   Invoice Price<span>{{invoice_amt | currency:"&#8377;"}}</span>

Percentage related point is mentioned in below link

Angular calculate percentage in the html

Use one more variable in your scope to check the type and based on that write the logic. Refer the Angular documentation https://docs.angularjs.org/api/ng/filter/currency

Community
  • 1
  • 1
kudlatiger
  • 3,028
  • 8
  • 48
  • 98