angularjs - How to specify locale different from default for currency with Angular currency filter? -


in our app using angular i18n/l10n. it's working fine.

there's problem though - user needs see info aligned locale, different current one. more specific - currency. e.g. - user's locale de-de , open catalog item prices in dollars. of course, can specify currency symbol explicitly:

{{item.price.value | currency : "$" : 2 }} 

but not graceful solution, because user see:

349,99 $ 

which not correct formatting. correct 1 be:

$349.99 

so, don't want change currency symbol, change whole currency formatting specific field , leave remaining on page localized according current locale.

is possible angular currency filter or should use own custom filter?

after looking through source code, determined angular using 'undefined' parameter trigger filter using default local currency. (see around line 14370 in angular 1.2.15)

thus, when chaining filters, can default value providing undefined parameter.

for you, following should give want:

{{item.price.value | currency : undefined : 2 }} 

that being said, 2 decimal places, have specified here, angular default. you'd 2 decimal places following filter:

{{item.price.value | currency}} 

Comments