在asc desc中排序数组

时间:2015-07-05 19:23:36

标签: angularjs sorting select

我是angularjs的新手这里是我的代码我想从网址获取数据,并通过从select元素中选择一个项目动态排序,但无法获得所需的结果请帮助我

HTML

$(function() {
    $( ".event" ).draggable( { 
        grid: [ 5, 0 ],
        containment: "parent"
        }).resizable({ 
            containment: "parent",
            grid: [ 5, 0 ],
            maxHeight: 40,
            maxWidth: 1000,
            minHeight: 40,
            minWidth: 60,
            handles: 'e, w',
            resize: function( event, ui ) {
                $( "#event" ).css("background-color", "blue");
            }
        });

        $( ".eventPeriod" ).droppable({
            activeClass: "ui-state-hover",
            hoverClass: "ui-state-active",
            drop: function( event, ui ) {
                $( this )
                    .addClass( "ui-state-highlight" );
                    return false;
            }
        });
});

代码

 <tr ng-repeat="x in names | orderBy: sortBy ">
      <td><a ng-href="{{ x.data.url}}">{{x.data.title}}</a>
      </td>
      <td>{{x.data.score}}</td>
 </tr>

Fiddle

1 个答案:

答案 0 :(得分:0)

https://jsfiddle.net/rr6q0umb/1/

为方向添加输入

<label><input type="checkbox" ng-model="direction">Reverse</label>

向您的orderBy过滤器添加方向值(反向为真)

<tr ng-repeat="x in names | orderBy:sortBy:direction">