在角1,我怎么能分页我的NG-重复? [英] In angular 1, how can I paginate my ng-repeats?

查看:129
本文介绍了在角1,我怎么能分页我的NG-重复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前限制我的NG-重复5使用过滤器,但我想知道我怎么能分页的数据。

I am currently limiting my ng-repeat to 5 using a filter, but I'm wondering how I can paginate the data.

<div ng-repeat="job in jobs | limitTo:5">

我有一个可变数目,我NG-通过重复的项目,我想用户能够查看在合理大块这些物品 - 在时间的五,下一/ previous按钮或页码跳过通过。是否有一个角指令非常适合这项任务?难道是简单处理来自后端与猫鼬查询发送管理的数据块?

I have a variable number of items that I am ng-repeating through, and I would like the user to be able to view these items in reasonable chunks -- five at a time, with next/previous buttons or page numbers to skip through. Is there an angular directive well-suited for this task? Would it be simpler to handle sending manageable chunks of data from the backend with a mongoose query?

推荐答案

是的,有一个为 AngularJS 一个不错的指令名为 dirPagination 。您可以分页,几乎你所需要的一切。

Yes, there's a nice directive for AngularJS called dirPagination. You can paginate tables and almost everything that you need.

看它在 Github上,如果​​你想看到演示, Plunker

Look at it on Github and if you want to see a demo, Plunker.

在你下载的的JavaScript 和模板 HTML 的文件,你需要做一些基本步骤:

After you downloaded the Javascript and template Html files, you need to do some basic steps:


  1. 在你的的JavaScript 文件,把

$ scope.currentPage = 1; //页面应该开始分页。结果
$ scope.pageSize = 5; //每页显示的限制

$scope.currentPage = 1; // The page that should start the pagination.
$scope.pageSize = 5; // The limit of items per page.

更​​改您的DIV:

&LT; D​​IV NG重复=作业工作| limitTo:5&GT; &LT; D​​IV DIR-PAGINATE =工作在工作​​|过滤器:q | itemsPerPage:pageSize的当前页=当前页&GT;&LT; / DIV&GT;

添加分页控件在HTML文件(一定要设置模板的正确的URL)。

Add the pagination controls in your html file (Be sure to set the correct url for the template).

&LT; D​​IR-分页,控制边界链接=真正的对网页变化=pageChangeHandler(newPageNumber)模板URL =dirPagination.tpl.html&GT;&LT; / DIR-分页的控件&GT;

更新

我做了一个 plnkr 证明它会怎样看你的情况。请看一看。

I made a plnkr to demonstrate how it would look in your case. Please, take a look.

这篇关于在角1,我怎么能分页我的NG-重复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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