mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
fix($locale): Allow currency filter to fall back to maxFrac from locale
- Modify default fallback to `NUMBER_FORMATS.PATTERNS[1].maxFrac` - Remove unnecessary resetting Closes #10179
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
*
|
||||
* @param {number} amount Input to filter.
|
||||
* @param {string=} symbol Currency symbol or identifier to be displayed.
|
||||
* @param {number=} fractionSize Number of decimal places to round the amount to.
|
||||
* @param {number=} fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale
|
||||
* @returns {string} Formatted number.
|
||||
*
|
||||
*
|
||||
@@ -61,8 +61,7 @@ function currencyFilter($locale) {
|
||||
}
|
||||
|
||||
if (isUndefined(fractionSize)) {
|
||||
// TODO: read the default value from the locale file
|
||||
fractionSize = 2;
|
||||
fractionSize = formats.PATTERNS[1].maxFrac;
|
||||
}
|
||||
|
||||
// if null or undefined pass it through
|
||||
|
||||
@@ -120,6 +120,12 @@ describe('filters', function() {
|
||||
expect(currency(0.008)).toBe('$0.01');
|
||||
expect(currency(0.003)).toBe('$0.00');
|
||||
});
|
||||
|
||||
it('should set the default fraction size to the max fraction size of the locale value', inject(function($locale) {
|
||||
$locale.NUMBER_FORMATS.PATTERNS[1].maxFrac = 1;
|
||||
|
||||
expect(currency(1.07)).toBe('$1.1');
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user