angular 负数遇到货币过滤器,负号会变成括号的解决办法
使用自定义货币过滤器:
//js中的代码,这是个判断货币正负的代码
var myApp = angular.module('myApp', []);
myApp.filter('customCurrency', ["$filter", function ($filter) {
return function(amount, currencySymbol){
var currency = $filter('currency');
if(amount < 0){
return currency(amount, currencySymbol).replace("(", "-").replace(")", "");
}
return currency(amount, currencySymbol);
};
}]);
var myApp = angular.module('myApp', []);
myApp.filter('customCurrency', ["$filter", function ($filter) {
return function(amount, currencySymbol){
var currency = $filter('currency');
if(amount < 0){
return currency(amount, currencySymbol).replace("(", "-").replace(")", "");
}
return currency(amount, currencySymbol);
};
}]);
我的segmentfault地址 : https://segmentfault.com/u/winward