为什么AngularJS货币筛选器用括号格式化负数?

Live Demo

为什么这个:

# Controller
$scope.price = -10;

# View
{{ price | currency }}

结果在($ 10.00)而不是 – $ 10.00?

这是代表负货币的流行方式。 Wikipedia

In bookkeeping,amounts owed are often represented by red numbers,or a number in parentheses,as an alternative notation to represent negative numbers.

你可以在Angular源代码中看到他们这样做(negSuf / negPre):

function $LocaleProvider(){
  this.$get = function() {
    return {
      id: 'en-us',NUMBER_FORMATS: {
        DECIMAL_SEP: '.',GROUP_SEP: ',',PATTERNS: [
          { // Decimal Pattern
            minInt: 1,minFrac: 0,maxFrac: 3,posPre: '',posSuf: '',negPre: '-',negSuf: '',gSize: 3,lgSize: 3
          },{ //Currency Pattern
            minInt: 1,minFrac: 2,maxFrac: 2,posPre: '\u00A4',negPre: '(\u00A4',negSuf: ')',lgSize: 3
          }
        ],CURRENCY_SYM: '$'
      },

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...