我有一张这样的表:
<tr ng-repeat="x in data | orderBy:xxxx">
<td>{{ x.name}}</td>
<td>{{ x.price * x.count }}</td>
</tr>
如何通过{{x.price * x.count}}列订购此表格行。
感谢您的帮助。
答案 0 :(得分:1)
orderBy
cab不仅接受一个值,还接受一个函数。为了在您的案例中使用它,请在您的范围中添加一个函数:
$scope.calculateOrder = function(item) {
return item.price * item.count;
};
然后您可以在过滤器中使用此功能:
<tr ng-repeat="x in data | orderBy:calculateOrder">
的更多信息
答案 1 :(得分:1)