AngularJS与BootStrap模仿百度分页的示例代码
来源:
中文源码网 浏览:159 次 日期:2024-05-15 15:03:24
【下载文档: AngularJS与BootStrap模仿百度分页的示例代码.txt 】
AngularJS与BootStrap模仿百度分页的示例代码
模仿百度的每页显示10条数据, 实现了当前页居中的算法.
BootStrap+AngularJS分页显示
序号 |
商品编号 |
名称 |
价格 |
---|
{{$index+1}} |
{{product.id}} |
{{product.name}} |
{{product.price}} |
1_1.json
{
"totalCount":100,
"products":[
{"id":"1001","name":"苹果手机","price":"5000"},
{"id":"1002","name":"三星手机","price":"6000"}
]
}
1_2.json
{
"totalCount":100,
"products":[
{"id":"1001","name":"华为手机","price":"5000"},
{"id":"1002","name":"vivo手机","price":"6000"}
]
}
实现的效果如图:
遇到的问题 : 下面的代码, 如果 把begin不小心写成了0 , 则页码上,会出现从0开始的bug
// 将页码加入 PageList集合
for(var i=begin ; i<= end ;i++){
$scope.pageList.push(i);
}
如下图所示
原因是begin代表的是页面显示的第一个页码, 如果i从0开始开始遍历, 那么pageList数组中的第一个元素就是0 ,因此在如下的angularJS的遍历页码的过程中, 就会从0开始遍历. 在页面上, 就会显示从0 开始
{{page}}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持中文源码网。