带有 ng-repeat 的 orderyBy 不起作用

orderyBy with ng-repeat not working

我正在尝试按答案之类的顺序排序。我查看了 orderBy 的 angular 文档,看起来我正在关注它。但是,我的 table 不是按喜欢排序的答案。这是我的 html。如果你想让我 post 更多代码,请告诉我。

<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>

如果您检查 Angular 的 orderBy example,您会注意到在没有 "object" 的情况下在 orderBy 中定义表达式的类比 (answer)

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