Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6dbd606

Browse files
Wesley ChoIgorMinar
Wesley Cho
authored andcommitted
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
1 parent 764fa86 commit 6dbd606

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/ng/filter/filters.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @param {number} amount Input to filter.
1313
* @param {string=} symbol Currency symbol or identifier to be displayed.
14-
* @param {number=} fractionSize Number of decimal places to round the amount to.
14+
* @param {number=} fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale
1515
* @returns {string} Formatted number.
1616
*
1717
*
@@ -61,8 +61,7 @@ function currencyFilter($locale) {
6161
}
6262

6363
if (isUndefined(fractionSize)) {
64-
// TODO: read the default value from the locale file
65-
fractionSize = 2;
64+
fractionSize = formats.PATTERNS[1].maxFrac;
6665
}
6766

6867
// if null or undefined pass it through

test/ng/filter/filtersSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ describe('filters', function() {
120120
expect(currency(0.008)).toBe('$0.01');
121121
expect(currency(0.003)).toBe('$0.00');
122122
});
123+
124+
it('should set the default fraction size to the max fraction size of the locale value', inject(function($locale) {
125+
$locale.NUMBER_FORMATS.PATTERNS[1].maxFrac = 1;
126+
127+
expect(currency(1.07)).toBe('$1.1');
128+
}));
123129
});
124130

125131

0 commit comments

Comments
 (0)