Angularjs Angular JS:orderBy与函数不工作
我的html:Angularjs Angular JS:orderBy与函数不工作,angularjs,Angularjs,我的html: <table class="table"> <thead> <tr> <th><a href="">Name</a></th> <th><a href="">Issued shares</a></th> <th><a hr
<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>
orderBy不起作用,我也不知道我哪里出了问题;关于orderBy的许多其他帖子并没有解决我的问题。有什么建议吗?表达式应该是函数,而不是包含函数调用的字符串 删除此行:
$scope.predicateBlueChip = 'marketCap()';
并直接使用marketCap
功能:
<tr ng-repeat="listing in listings | orderBy:marketCap:reverseBlueChip">
我希望能够将其与其他标题一起排序(我只是将其取出以避免混淆)。因此orderBy必须是作用域上的谓词属性。如何将marketCap分配给谓词以使其工作?$scope.predicateBlueChip=$scope.marketCap代码>(但此行必须在定义了$scope.marketCap
之后。感谢您的完整性:ng click=“predicate=marketCap;
和{marketCap(清单)| currency:'R'}}
和$scope.predicate=$scope.marketCap;
有效(仅供参考,我删除了蓝筹码)
<tr ng-repeat="listing in listings | orderBy:marketCap:reverseBlueChip">