简体   繁体   English

Angular.js中的分页

[英]Pagination in Angularjs

I am currently trying to build a simple CRUD application for beginners of Angularjs. 我目前正在尝试为Angularjs的初学者构建一个简单的CRUD应用程序。 I am using Angularjs + Firebase + Bootstrap for that. 我正在为此使用Angularjs + Firebase + Bootstrap。

Here is the --- plnkr --- for that. 这是--- plnkr ---。

I just wanna add a new feature is the simple pagination for that. 我只是想添加一个新功能,就是简单的分页。 I think 我认为

$filter('filter')(array, expression, comparator)

may help but I don't know how. 可能有帮助,但我不知道如何。

Can anyone please help me !!!!? 谁能帮帮我吗 !!!!?

Angular provides filters that are perfect for pagination: startFrom and limitTo. Angular提供了最适合分页的过滤器:startFrom和limitTo。 This JSFiddle is a great base example of how that works. 这个JSFiddle是一个很好的基础示例。 The key is to have in your scope a page index, and a page size. 关键是在您的范围内具有页面索引和页面大小。 You can then change what page you are viewing simply by increasing/decreasing your page index. 然后,您可以通过增加/减少页面索引来更改正在查看的页面。

You can see how it works with this piece of HTML 您可以看到它如何与这段HTML一起工作

<li ng-repeat="item in data | startFrom:currentPage*pageSize | limitTo:pageSize">
    {{item}}
</li>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM