Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular orderBy evaluate expression

I would like my orderBy to evaluate an expression

Currently I have:

ng_repeat: "post in posts | orderBy:"up_votes"

I would like it instead to order by {{up_votes - down_votes}}

like image 604
bsiddiqui Avatar asked Aug 13 '26 07:08

bsiddiqui


1 Answers

ng_repeat: "post in posts | orderBy:'down_votes - up_votes'"

Just use single quotes to wrap the expression for orderBy

Or you could add a voteDiff function to the controller and do orderBy:voteDiff

like image 142
Shawn Balestracci Avatar answered Aug 15 '26 03:08

Shawn Balestracci