在角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:
-
在你的
的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; DIV NG重复=作业工作| limitTo:5&GT;
到&LT; DIV 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; DIR-分页,控制边界链接=真正的对网页变化=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.