我的html:
<table class="table">
<thead>
<tr>
<th><a href="">Name</a></th>
<th><a href="">Issued shares</a></th>
<th><a href="">Closing price</a></th>
<th><a href="" ng-click="predicateBlueChip = 'marketCap()'; reverseBlueChip = !reverseBlueChip">Market capitalisation</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="listing in listings | orderBy:predicateBlueChip:reverseBlueChip">
<td><a ng-href="#/browse/listing/{{ listing.id }}">{{ listing.name_short }}</a></td>
<td>{{ listing.last_price.issued_shares }}</td>
<td>{{ listing.last_price.price_close }}</td>
<td>{{ marketCap(listing) | currency:'R' }}</td>
</tr>
</tbody>
</table>
控制器:
$scope.predicateBlueChip = 'marketCap()';
$scope.reverseBlueChip = true;
$scope.marketCap = function(listing) {
return Math.round(listing.last_price.price_close * listing.last_price.issued_shares / 1000000);
}
orderBy 不起作用,我不确定哪里出错了;关于 orderBy 的许多其他帖子并没有解决我的问题。有什么建议么?