[AngularFire2] Pagination
Let's see how to do pagination in Firebase:
For the init loading, we only want 3 items:
findLessonsKeyPreCourseUrl(courseUrl) {
return this.findCourseByUrl(courseUrl)
.filter(course => !!course)
.map((course) => course.$key)
.switchMap((courseKey) => this.db.list(`lessonsPerCourse/${courseKey}`, {
query: {
limitToFirst: ,
orderByKey: true
}
}));
}
'limitToFirst' --> If not given 'startAt', will start from index 0, and get three items.
Next page: The idea is getting 4 items from the previous page's last item, after that we get rid of first item only keep the rest:
findNextPageLessonsKey(courseUrl: string, from: Lesson, limit: number){
return this.findCourseByUrl(courseUrl)
.filter(c => !!c)
.switchMap((c) => this.db.list(`lessonsPerCourse/${c.$key}`, {
query: {
limitToFirst: limit + ,
orderByKey: true,
startAt: from.$key
}
}))
.map(lessons => lessons.slice(, lessons.length));
}
Previous Page: The same idea as next page, difference is this time we get 4 item from next page's first item, then get rid of the last item only keep the rest:
findPreviousPageLessonsKey(courseUrl: string, end: Lesson, limit: number){
return this.findCourseByUrl(courseUrl)
.filter(c => !!c)
.switchMap((c) => this.db.list(`lessonsPerCourse/${c.$key}`, {
query: {
limitToLast: limit + ,
orderByKey: true,
endAt: end.$key
}
}))
.map(lessons => lessons.slice(, lessons.length-));
}
[AngularFire2] Pagination的更多相关文章
- pagination 分页
<!DOCTYPE html> <html> <head> <title>pagination</title> <style type ...
- salesforce 零基础学习(四十九)自定义列表分页之使用Pagination实现分页效果 ※※※
上篇内容为Pagination基类的封装,此篇接上篇内容描述如何调用Pagination基类. 首先先创建一个sObject,起名Company info,此object字段信息如下: 为了国际化考虑 ...
- salesforce 零基础学习(四十八)自定义列表分页之Pagination基类封装 ※※※
我们知道,salesforce中系统标准列表页面提供了相应的分页功能,如果要使用其分页功能,可以访问http://www.cnblogs.com/zero-zyq/p/5343287.html查看相关 ...
- knockoutjs+ jquery pagination+asp.net web Api 实现无刷新列表页
Knockoutjs 是一个微软前雇员开发的前端MVVM JS框架, 具体信息参考官网 http://knockoutjs.com/ Web API数据准备: 偷个懒数据结构和数据copy自官网实例 ...
- ajax pagination 布局刷新
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...
- jq pagination分页 全选、单选的思考
$().pagination(总条数,配置项); 后端分页的跨页选择: 思路:把浏览过的页整体保存为,整体拥有 curPage(当前页码).allChoice(当前页是否全选).selected当前页 ...
- 分享一个Jquery 分页插件 Jquery Pagination
分页插件来说,我觉得适用就行,尽量简单然后能够根据不同的应用场景能够换肤.展现形式等. 对于初学者想写分页插件的同学,也可以看下源码,代码也挺简单明了的,也助于自己写个小插件. 不过我比较懒,一般直接 ...
- jQuery Pagination分页插件的使用
一.引用CSS和JS: <link href="/Content/Plugins/jQuery.Pagination_v2.2/pagination.css" rel=&qu ...
- web 前端常用组件【01】Pagination 分页
分页组件几乎是一般网站都会涉及到的组件,网上有很多这样的插件,自己挑来跳去选择了这一款. 官方Demo网址:http://mricle.com/JqueryPagination 功能强大,可扩展性比较 ...
随机推荐
- Autoencoders and Sparsity(一)
An autoencoder neural network is an unsupervised learning algorithm that applies backpropagation, se ...
- Kinect 开发 —— 深度信息(二)
转自(并致谢):http://www.cnblogs.com/yangecnu/archive/2012/04/05/KinectSDK_Depth_Image_Processing_Part2.ht ...
- linux的dhcp4.1.1服务部署
Centos6.5的dhcp4.1.1服务部署 实施步骤: 1:设置DHCP服务器静态IP和主机名 [root@sw ~]# vim /etc/sysconfig/network-scripts/i ...
- nohup---将程序以忽略挂起信号的方式运行起来
nohup nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令.该命令可以在你退出帐户/关闭终端之后继续运行相应的进程. 在缺省情况下该作业的所 ...
- js20---接口3种方式
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- 3.JPA开发
转自:https://blog.csdn.net/aspnetandjava/article/details/7034779 1. 什么是JPA 1. JPA(Java Persistence API ...
- 1.5 Upgrading From Previous Versions官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ 1.5 Upgrading From Previous Versions 1.5 从 ...
- MySQL乱码问题以及utf8mb4字符集---utf8mb4和utf8有什么区别? emoji表情与utf8mb4
utf8mb4兼容utf8,且比utf8能表示更多的字符. 关于emoji表情的话mysql的utf8是不支持,需要修改设置为utf8mb4,才能支持, 因为utf8mb4是utf8的超集
- Linux文本编辑器
1.编辑模式 2.命令模式 3.底部命令模式 注意:如果发现编辑不了.可能是因为非法退出产生一个后缀名为.swp 的临时隐藏文件. 将其删除重新编辑即可!
- VBS 脚本调用
https://my.oschina.net/Tsybius2014/blog/602641