javascript - Reverse the sort order in Angular -
i have list of products , prices pass angular iterator. user can select option drop down allows them sort 1 of properties associated objects. when try , reverse order alphabetic properties order doesn't work.
see jsfiddle here: http://jsfiddle.net/pga6yaxg/
else if ($scope.orderby == 'name-za') { return -result.name;
click on added, price , name a-z , these work fine, when choose z-a order incorrect. ideas?
i modified fiddle make work.
basically, added reverse
variable, in angularjs orderby documentation:
<li data-ng-repeat="orderby : [orderbyoptions, recent] : reverse track $index">
it works now!
update
by way, have spared whole filtering in controller assigning predicate
value actual value of <option>
tag , binding orderby filter model of <select>
. way not use reverse
variable!
check other jsfiddle improved version.
Comments
Post a Comment