我希望在角度js中设置默认排序管理图标

时间:2015-01-04 07:04:01

标签: javascript angularjs

我是角度js的新手。我已经设置了排序。当我设置dafault设置时,我的排序箭头可见。我想喜欢用mange我的图标进行默认排序。请帮帮我。提前致谢 。

   <table style="border: 1px solid " class="table table-striped">
                <thead>
                    <tr>


                        <th ng-click="orderByField='JackpotAmount'; reverseSort = !reverseSort" class="link">
                            <a href="">
                                JackPot Amount <span ng-show="orderByField == 'JackpotAmount'"><span ng-show="!reverseSort" class="glyphicon glyphicon-chevron-up"></span><span ng-show="reverseSort" class="glyphicon glyphicon-chevron-down"></span></span>
                            </a>

                        <th ng-click="orderByField='StartDate';  reverseSort = !reverseSort" class="link">
                            <a href="">
                                Start Date <span ng-show="orderByField == 'StartDate'"><span ng-show="!reverseSort" class="glyphicon glyphicon-chevron-up"></span><span ng-show="reverseSort" class="glyphicon glyphicon-chevron-down"></span></span>
                            </a>


                        </th>
                        <th ng-click="orderByField='EndDate'; reverseSort = !reverseSort" class="link">
                            <a href="">
                                End Date <span ng-show="orderByField == 'EndDate'"><span ng-show="!reverseSort" class="glyphicon glyphicon-chevron-up"></span><span ng-show="reverseSort"     class="glyphicon glyphicon-chevron-down"></span></span>
                            </a>


                        </th>

                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="jackpots1 in listjackpot|orderBy:sort:reverseSort">

                        <td>{{ jackpots1.JackpotAmount }}</td>
                        <td>{{ jackpots1.StartDate  }}</td>
                        <td>{{ jackpots1.EndDate }}</td>


                    </tr>
                </tbody>
            </table>

下面是我的控制器

    $scope.orderByField = 'StartDate';
    $scope.reverseSort = true;

1 个答案:

答案 0 :(得分:0)

你很亲密。 orderBy参数是错误的变量名。

orderBy:orderByField:reverseSort

而不是

orderBy:sort:reverseSort