查了一下可以透過自定的currency來解決,請參考以下這篇討論串:
http://stackoverflow.com/questions/14782439/removing-angularjs-currency-filter-decimal-cents
新增noFractionCurrency
var myAppFilter = angular.module('myApp.filters',[]); myAppFilter.filter('noFractionCurrency', [ '$filter', '$locale', function(filter, locale) { var currencyFilter = filter('currency'); var formats = locale.NUMBER_FORMATS; return function(amount, currencySymbol) { var value = currencyFilter(amount, currencySymbol); var sep = value.indexOf(formats.DECIMAL_SEP); console.log(currencySymbol); if(amount >= 0) { return value.substring(0, sep); } return value.substring(0, sep) + ')'; }; } ]);
使用方法
{{money| noFractionCurrency :''}}//第一個參數為單位字串
沒有留言:
張貼留言
留個話吧:)