自定义排序功能这是我的代码额外的参数传递到AngularJS
<a href="" ng-click="predicate = 'productname'; reverse=false">Productname</a>
<a href="" ng-click="predicate = 'productprice'; reverse=false">Productprice</a>
迭代
<div ng-repeat="sale in sales | orderBy:customSort">
Customsort功能
$scope.customSort = function(sale) {
};
目前在customSort功能我得到的所有销售数据,但我也希望将谓词值传递给该函数,以便它可以相应地进行排序(如果是nam,则按名称排序e被点击,如果价格谓词被点击则按价格排序。)
如何将谓词值传递给customSort函数?任何人都可以帮助我解决这个问题吗?谢谢。
使用冒号标记分隔参数[见过滤文档( https://docs.angularjs.org/guide/filter) – charlietfl
@charlietfl这应该是一个答案 – Valerij
@charlietfl [orderBy](https://docs.angularjs.org/api/ng/filter/orderBy)似乎只是采取一个表达 –