将AngularJS Currency Locale添加到末尾

Adding the AngularJS Currency Locale to the end

本文关键字:添加 Locale AngularJS Currency      更新时间:2023-12-26

我有以下标记:

<div class="full">
    <dl class="no-margin">
        <dt ng-if="foo.IsLoading" class="no-margin text--plain">
        <img alt="Load animation" src="load_small.gif"/> Loading
        </dt>
        <dt ng-if="!foo.IsLoading" class="no-margin text--plain">{{foo.BalanceLabel}}</dt>
        <dd class="h3 text--plain" ng-class="{' text--negative': model.IsNegativeBalance(foo.BalanceValue)}">{{foo.BalanceValue | currency:"CAD"}}</dd>
    </dl>
</div>                 

唯一的问题是,它将3位数的值添加到值的开头:"CAD1234.56"或"-CAD1233.56"

这对美元来说很好,因为我们希望美元在前面。然而,我的设计要求国外的3位数字位于金额末尾:"1234.56 CAD"或"-1234.56 CAD"

我还可以使用Angular货币API来实现这一点吗?

使用货币过滤器无法解决此问题。你有两个选择来解决你的问题。

修复1:

使用i18n角度(例如de)

<script src="i18n/angular-locale_de-de.js"></script>

修复2:

使用带有货币的过滤器编号而不使用货币过滤器

{{foo.BalanceValue | number:2}}CAD

对于修复1,我不确定是否使用货币CAD。我只尝试用欧元。