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: '$' },
原文地址:https://www.jb51.cc/angularjs/145434.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。