[英]How can I overwrite the default of angularjs to use parenthesis (()) around negative numbers instead of the minus (-) sign?
Here is the $provided in the angular.js file that forces negative numbers to have the minus sign. 这是angular.js文件中提供的$,用于强制负数带有减号。 I would rather not modify the angular.js source code.
我宁愿不修改angular.js源代码。
$provide.value("$locale", {
"DATETIME_FORMATS": {
*
*
*
"NUMBER_FORMATS": {
"CURRENCY_SYM": "$",
"DECIMAL_SEP": ".",
"GROUP_SEP": ",",
"PATTERNS": [
{
"gSize": 3,
"lgSize": 3,
"maxFrac": 3,
"minFrac": 0,
"minInt": 1,
"negPre": "-",
"negSuf": "",
"posPre": "",
"posSuf": ""
},
{
"gSize": 3,
"lgSize": 3,
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "-\u00a4",
"negSuf": "",
"posPre": "\u00a4",
"posSuf": ""
}
]
},
*
*
*
I want to overwrite this behavior and have a custom configuration file that will give negative numbers parenthesis instead of the negative sign. 我想覆盖此行为,并有一个自定义配置文件,该文件将给负号括号而不是负号。
Current output: -48.25 Desired output: (48.25) 电流输出:-48.25所需输出:(48.25)
What about: 关于什么:
"PATTERNS": [
{
"gSize": 3,
"lgSize": 3,
"maxFrac": 3,
"minFrac": 0,
"minInt": 1,
"negPre": "(",
"negSuf": ")",
"posPre": "",
"posSuf": ""
},
{
"gSize": 3,
"lgSize": 3,
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00a4",
"posSuf": ""
}
]
Try changing negPre
and negSuf
: 尝试更改
negPre
和negSuf
:
$provide.value("$locale", {
"DATETIME_FORMATS": {
*
*
*
"NUMBER_FORMATS": {
"CURRENCY_SYM": "$",
"DECIMAL_SEP": ".",
"GROUP_SEP": ",",
"PATTERNS": [
{
"gSize": 3,
"lgSize": 3,
"maxFrac": 3,
"minFrac": 0,
"minInt": 1,
"negPre": "(",
"negSuf": ")",
"posPre": "",
"posSuf": ""
},
{
"gSize": 3,
"lgSize": 3,
"maxFrac": 2,
"minFrac": 2,
"minInt": 1,
"negPre": "(\u00a4",
"negSuf": ")",
"posPre": "\u00a4",
"posSuf": ""
}
]
},
*
*
*
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.