問題描述
如何區分 Rs 和 % 值? (How to differentiate Rs and % values?)
在我的購物車應用程序中,我從服務器獲取價格和百分比報價。我需要用盧比區分價格值和百分比值。和 %。
這是我在控制器中的代碼:
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;
}
我在 HTML 中將值設為 {{invoice_amt}} 如何在 rs 中顯示優惠。和百分比。
參考解法
方法 1:
You have to use currency filter, this below sample will print in Rupees ( ₹ )
Invoice Price<span>{{invoice_amt | currency:"₹"}}</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
(by Vignesh、kudlatiger)