feat(common): allow default currency code to be configurable (#34771)

Default currency code in CurrencyPipe is currently hardcoded to USD
and is not configurable. This commit allows the default currency code
to be configurable by adding a DEFAULT_CURRENCY_CODE injection token.

Example:
```
providers: [{ provide: DEFAULT_CURRENCY_CODE, useValue: "GBP" }]
...
{{ 123.45 | currency }} // outputs £123.45 as opposed to always $123.45 before
```

Closes: #25461

PR Close #34771
This commit is contained in:
Hayouung
2019-12-14 10:39:41 +00:00
committed by atscott
parent d318249125
commit 965f5575c7
9 changed files with 52 additions and 10 deletions

View File

@ -89,7 +89,7 @@ import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testin
describe('CurrencyPipe', () => {
let pipe: CurrencyPipe;
beforeEach(() => { pipe = new CurrencyPipe('en-US'); });
beforeEach(() => { pipe = new CurrencyPipe('en-US', 'USD'); });
describe('transform', () => {
it('should return correct value for numbers', () => {