【发布时间】:2016-07-24 21:30:08
【问题描述】:
我正在尝试按答案之类的排序。我查看了 orderBy 的角度文档,看起来我正在关注它。但是,我的桌子不是按喜欢的人排序的。这是我的html。如果您希望我发布更多代码,请告诉我。
<div ng-controller="answerAndQuestionController">
<h1 ng-bind='question.question'></h1>
<h1 ng-bind='question.description'></h1>
<table>
<thead>
<tr>
<th>Answer</th>
<th>Description</th>
<th>User</th>
<th>Likes</th>
</tr>
</thead>
<tbody>
<tr ng-repeat = "answer in answers | orderBy:'answer.likes'">
<td><input ng-model = "answer.answer" readonly></td>
<td><input ng-model = "answer.description" readonly></td>
<td><input ng-model = "answer.user" readonly></td>
<td><input ng-model = "answer.likes" readonly>
<button ng-click = "like(answer.answer)" href="">like</button>
</td>
</tr>
</tbody>
</table>
</div>
【问题讨论】:
-
尝试不使用
answer,就像这样<tr ng-repeat = "answer in answers | orderBy:'likes'"> -
谢谢,把它贴出来,这样我就可以给你答案了
标签: html angularjs ng-repeat angularjs-orderby