0
我在模板上做了一些数学计算,有时结果是负数。 我的问题是,当结果是一个负数,它显示一个括号包装它。我该如何解决它? 使用Angular 1.2。角度显示负数的括号
我的控制器:
$scope.totalToReceive = totalToReceive;
$scope.discountedTotal = discount;
$scope.antecipatedTotal = antecipatedTotal;
$scope.totalReceived = totalToReceive - discount + antecipatedTotal;
我的模板:
<li>
<span class="big-number"><span>R$</span> {{ totalReceived | currency: ""}}</span>
</li>
更新: 我试着写我自己的过滤器,但它没有工作
.filter('numeric', function(){
return function (value) {
if (value < 0) {
value = '-' + Math.abs(value) + '';
}
}
})
这就是[货币过滤器是]什么(https://docs.angularjs.org/api/ng/filter/currency)..如果你想要不同的行为,你需要编写你自己的过滤器。 –
@MikeMcCaughan我试过了。我会更新我的问题。 – vbotio
剥离圆括号过滤器可以在这里找到:http://stackoverflow.com/questions/31532393/angularjs-remove-currency-filter- paranthesis – Adrianopolis