2
本質上,我需要在表格的標題中添加一個小按鈕或某些內容,以便按列按字母順序對數據進行排序。我在使用AngularJS時遇到了麻煩,需要一些幫助。如何使用AngularJS將字母列排序添加到表格
這是顯示錶和......片段
<div class="col-md-10">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>Status</th>
<th>Ref</th>
<th>Service</th>
<th>Domain</th>
<th>Service Owner</th>
<th>Stage</th>
</tr>
</thead>
<tbody>
<tr ng-click="isCollapsed = !isCollapsed" ng-repeat-start="x in projects | filter:query | filter:myFilter | orderBy:orderProp">
<td><b>{{x.a}}</b></td>
<td>{{x.b}}</td>
<td><u>{{x.c}}</u></td>
<td>{{x.d}}</td>
<td>{{x.e}}</td>
<td>{{x.f}}</td>
</tr>
<tr collapse="isCollapsed" ng-repeat-end="">
<td colspan="6">
<h3>Test</h3>
<p>Test</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
這是代碼的plnkr http://plnkr.co/edit/OkRbR9geeOcCGy2K01jB?p=preview
我試過的東西非常接近,但我明白爲什麼它沒有工作。我使用了'ng-click',但我沒有將它附加到可點擊的屬性上,只是'
如果我想在點擊反轉排序之間進行切換,我將如何去做這件事?我嘗試了各種各樣的東西,但無濟於事。 – TheLimeTrees
orderBy的文檔似乎完全符合您的要求:https://docs.angularjs.org/api/ng/filter/orderBy – bm1729
相關問題