Angularjs 如何区分Rs和%值?
在我的购物车应用程序中,我从服务器获得价格和百分比的优惠。 我需要用卢比和%区分价格值和百分比值 以下是我在控制器中的代码:Angularjs 如何区分Rs和%值?,angularjs,logic,shopping-cart,ng-repeat,Angularjs,Logic,Shopping Cart,Ng Repeat,在我的购物车应用程序中,我从服务器获得价格和百分比的优惠。 我需要用卢比和%区分价格值和百分比值 以下是我在控制器中的代码: if(result.type == 'Price'){ $scope.invoice_amt = $scope.invoice_amt - result.offer ;
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\u amt}
如何以卢比和百分比显示报价。您必须使用货币过滤器,下面的示例将以卢比打印(₹ )强>
Invoice Price<span>{{invoice_amt | currency:"₹"}}</span>
发票价格{{发票金额}货币:₹;}
下面的链接中提到了相关的百分比
在您的作用域中再使用一个变量来检查类型,并在此基础上编写逻辑。请参阅相关文档