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:
Wesley Cho
2014-11-22 10:50:54 -08:00
committed by Igor Minar
parent 764fa869dd
commit 6dbd606ad7
2 changed files with 8 additions and 3 deletions

View File

@@ -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

View File

@@ -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');
}));
});