1
를 작동하지 않는 나의 HTML :각도 JS : 해 orderBy 기능
<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에 대한 수많은 게시물이 내 문제를 해결하지 못했습니다. 어떤 제안?
을 (난 그냥 피하기 위해 그것을 꺼내서 혼동). 따라서 orderBy는 범위의 조건부 속성이어야합니다. marketCap을 작동시키기위한 술어에 어떻게 할당합니까? – Tjorriemorrie
'$ scope.predicateBlueChip = $ scope.marketCap;'(그러나이 줄은'$ scope.marketCap'이 정의 된 후에 이루어져야합니다.) –
감사합니다, 완전성을 위해 : 'ng-click = "술어 = marketCap;과'