如何在角度js中显示来自完整对象的排序数据? [英] how to display sorted data from complete object in angular js?

本文介绍了如何在角度js中显示来自完整对象的排序数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作排序数据的演示并显示在表格上.实际上,在我的演示中,我正在访问一项服务,其中包含一些数据 (2000) 对象作为响应.所以我一次显示 50 个对象并使用无限滚动我加载了更多工作正常的数据.当我滚动到底部时,我能够加载更多数据.我的标题^"或V"上有按钮.请检查标题(左图标V")示例帐户名称V""我需要使用这个 I 图标对我的列进行排序.

I am trying to make demo of sorted data and display on table.Actually In my demo I am hitting a service got some data (2000) objects in that as a response.So I am display 50 objects at one time and using infinite scroll I load more data which is working fine .I am able to load more data when I scroll to bottom .There is buutton on my header "^" or "V" .Please check on header (left icon "V") Example "Account Name "V"" Using this I icon I need to sort my column .

实际上问题是当前它对屏幕上显示的唯一 50 元素进行排序.当用户滚动到底部并加载更多 50元素它排序 100 元素等等..但这不是正确的解决方案.我需要 排序 2000 个元素(所有来自服务的对象)并显示前 50 个元素当用户滚动到底部时,它会加载更多 50 个元素,我们可以使用 Angular js 来做吗

Actually The issue is current it sorting the only 50 element which is display on screen .When user scroll to bottom and load more 50 element it sort 100 element so on..But it is not correct solution.I need to sort 2000 element (all object which is coming from service) and display first 50 elements and when user scroll to bottom it load more 50 elements can we do in using angular js

这是我的代码

http://plnkr.co/edit/rUxTGDqyrxVq9STdvDTV?p=preview

<ion-scroll scrollbar-y="true" delegate-handle="invoicegrid" ng-style="viewHeight">
  <div class="row" ng-repeat="column in invoice_records | limitTo: counter | orderBy: sortval:reverse track by $index" ng-class-odd="'odd-row'">
    <div class="col brd collapse-sm" ng-repeat="field in column.columns" ng-show="invoice_column_name[$index].checked && invoice_column_name[$index].fieldNameOrPath===field.fieldNameOrPath">{{field.value}}</div>
    <div class="col col-10 text-center brd collapse-sm"></div>
  </div>
</ion-scroll>
<ion-infinite-scroll immediate-check="false" on-infinite="loadMore(query)" distance="10%"></ion-infinite-scroll>

Java 脚本

  $scope.setSort = function(idx, reverse){
    $scope.sortval = 'columns['+idx+'].value';
    $scope.reverse = reverse;
  };

推荐答案

您可以根据服务的结果调用订单:

You can call the order by on the results from your service:

$scope.total_invoice_records = $filter('orderBy')(data.records, 'columns['+idx+'].value', true)

这篇关于如何在角度js中显示来自完整对象的排序数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆