加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 08:32:03 所属栏目:安全 来源:网络整理
导读: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 pa
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: '$'
      },

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读