Aaron Aaron - 1 year ago 91
AngularJS Question

orderyBy with ng-repeat not working

I am trying to order by the likes of an answer. I looked at the angular documentation for orderBy and it looks like I am following it. However, my table is not ordering by the likes for answer. Here is my html. If you want me to post more code let me know.

<div ng-controller="answerAndQuestionController">
<h1 ng-bind='question.question'></h1>
<h1 ng-bind='question.description'></h1>
<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>

Answer Source

If you check Angular's orderBy example you'll notice the analogy to define expression in orderBy without "object" (answer)

<tr ng-repeat = "answer in answers | orderBy:'likes'">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download