在 angular 货币过滤器中有没有办法输出像 152€ 这样的价格?

Is there a way in angular currency filter to output price like 152€?

有什么办法可以输出这样的价格吗? 152 欧元.

如果我使用 angular 货币过滤器,它会输出 152 欧元。

谢谢。

试试这个..

在控制器中

$scope.currency = 152; $scope.currencySymbol = '$';

在标记中

{{currency| number}}{{currencySymbol}}

使用定义的行为创建自定义过滤器

.filter('customCurrency',function()
    {
        return function(amount){
            return amount+"$";
        }
    });

Here is a Fiddle for the same http://jsfiddle.net/s6vjjoLs/

Divya 的答案很好但不完整,因为 angular 货币过滤器不仅仅在金额后添加货币符号。它还会截断到点后的正确位数,请查看 documentation。 我认为最好的方法是正确使用内部使用 angular 过滤器的新过滤器:

angular.module('myApp', [])
.filter('customCurrency',function($filter)
        {
            return function(amount, symbol, fractionSize){
                var result = $filter("currency")(amount, symbol, fractionSize);
                result = result.slice(symbol.length, result.length) + result.slice(0,symbol.length);
                return result;
            }
        });
    
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
    <div>{{ 42.6732 | customCurrency : 'euro'}}</div>    
</body>