When working on my template, I encounter a math issue where the result sometimes turns out to be a negative number. The problem is that when this happens, it displays the number within parentheses. How can I fix this using Angular 1.2?
This is my controller:
$scope.totalToReceive = totalToReceive;
$scope.discountedTotal = discount;
$scope.antecipatedTotal = antecipatedTotal;
$scope.totalReceived = totalToReceive - discount + antecipatedTotal;
Here is my template:
<li>
<span class="big-number"><span>R$</span> {{ totalReceived | currency: ""}}</span>
</li>
Update: I attempted to create my own filter, but unfortunately it did not work as intended.
.filter('numeric', function(){
return function (value) {
if (value < 0) {
value = '-' + Math.abs(value) + '';
}
}
})