I want to find the difference between two numbers in anuglar js directive tags.
<div ng-repeat="post in posts | orderBy:'-upvotes'">
<span class="glyphicon glyphicon-thumbs-up"
ng-click="incrementUpvotes(post)"></span>
{{post.upvotes}}
<span class="glyphicon glyphicon-thumbs-down"
ng-click="incrementDownvotes(post)"></span>
{{post.downvotes}}
<span class="glyphicon glyphicon-glyphicon-minus"></span>
<span class="glyphicon glyphicon-glyphicon-plus"></span>
{{post.upvotes - post.downvotes}} // I want the difference of these two numbers
There has to be a way to do this using the absolute value of the two numbers, or using some angular method to find the difference between them. Currently with the above code it will execute the equation, but it does strict subtraction, not giving me the actual difference between these numbers.
Aucun commentaire:
Enregistrer un commentaire