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

fix(currencyFilter): trim currency string #15085

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/filter/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function currencyFilter($locale) {
return (amount == null)
? amount
: formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, fractionSize).
replace(/\u00A4/g, currencySymbol);
replace(/\u00A4/g, currencySymbol).trim();
};
}

Expand Down
6 changes: 6 additions & 0 deletions test/ng/filter/filtersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ describe('filters', function() {

expect(currency(1.07)).toBe('$1.1');
}));

it('should trim the currency string if there are spaces before or after the currency string', inject(function($locale) {
$locale.NUMBER_FORMATS.PATTERNS[1].posPre = ' ';

expect(currency(1.07, '')).toBe('1.07');
}));
});

describe('number', function() {
Expand Down