lundi 29 juin 2015

Orderby weighted average in angular

I am trying to sort a table by a weighted average of two columns. The weights for the columns are stored in a controller's scope. When I try to refer to these weights in my orderBy expression sorting is not done correctly.

 <tr ng-repeat = "x in fruitdata | orderBy:'cost.apples*apples + cost.oranges * oranges'">

Fiddle of what I want: http://ift.tt/1SYKxdZ

If I hard code weights instead everything works as it should

 <tr ng-repeat = "x in fruitdata | orderBy:'1.89*apples + 1.49 * oranges'">

Fiddle with hard coded weights (not what I want): http://ift.tt/1KpDQQI

Aucun commentaire:

Enregistrer un commentaire