【发布时间】:2014-09-05 09:59:54
【问题描述】:
我使用 .00 货币过滤器来自:AngularJS currency filter: can I remove the .00 if there are no cents in the amount?
但是,如何调整过滤器以按逗号分割值?
例如,
而不是 456789 英镑 它应该显示:456,789 英镑
这是我制作的一个 plunker:http://plnkr.co/edit/uDFWkPAmc7PrgDwHPDho?p=preview
过滤器:
app.filter('myCurrency', ['$filter', function ($filter) {
return function(input) {
input = parseFloat(input);
if(input % 1 === 0) {
input = input.toFixed(0);
}
return '£' + input;
};
}]);
【问题讨论】:
标签: angularjs angularjs-scope angular-filters