1)下拉刷新用的是 ion-refresher,使用示例如下:

<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="doRefresh()">
</ion-refresher>

详情说明请看官方文档:http://ionicframework.com/docs/api/directive/ionRefresher/

刷新后需要收起 loading 动画

$scope.$broadcast('scroll.refreshComplete');  

2)上拉加载用的是 ion-infinite-scroll,使用示例如下:

<ion-infinite-scroll
on-infinite="loadMore()"
distance="1%">
</ion-infinite-scroll>

详情说明请看官方文档:http://ionicframework.com/docs/api/directive/ionInfiniteScroll/

加载完之后需要收起 loading 动画

$scope.$broadcast('scroll.infiniteScrollComplete');

PS:需要注意的是这两个功能标签都是需要写在 ion-content 标签里的,不然会出错

来一个完整的demo:

html部分

<ion-view view-title="{{title}}" id="category">
<ion-nav-buttons side="left" class="has-header">
<button class="button button-icon icon ion-ios-arrow-back" ui-sref="page6"></button>
</ion-nav-buttons>
<ion-nav-buttons side="right" class="has-header">
<button class="button button-icon icon ion-android-home" ui-sref="page6"></button>
</ion-nav-buttons>
<ion-content padding="true" class="has-header">
<ion-refresher
pulling-text="Pull to refresh..."
on-refresh="doRefresh()">
</ion-refresher>
<ion-list id="page5-list5">
<ion-item ng-repeat="item in lists" class="item-grid-two" id="page5-list-item{{item.product_id}}">
<div class="pic">
<a href="/wap/product-{{item.product_id}}.html">
<img src="http://pics.imopark.com/{{item.default_image}}"></a><i></i>
</div>
<div class="product-info">
<div class="p-price-bar">
<span class="fl p-price"> <em class="price">¥{{item.price}}</em>
</span>
<span class="fl p-discount"> <em class="">{{item.zk}}折</em>
</span>
<span class="fr p-sale-num">已售 {{item.codersum}}</span>
</div>
<h2 class="p-name">
<a href="/wap/product-{{item.product_id}}.html" class="split">{{item.name}}</a>
</h2>
</div>
</ion-item>
</ion-list>
<ion-infinite-scroll
ng-if="can_loadmore()"
on-infinite="loadMore()"
distance="1%">
</ion-infinite-scroll>
</ion-content>
</ion-view>

js部分

angular.module('app.controllers', [])

.controller('categoryCtrl', ['$scope', '$http', '$stateParams','$ionicLoading', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName
function ($scope, $http, $stateParams, $ionicLoading) {
var _arguments = arguments;
$scope.lists = [];
var page_no = 1;
var page_size = 20;
var page_total = 0; $scope.can_loadmore = function(){
return page_no<page_total;
}; $scope.$on('$ionicView.loaded', function(event, data) {
page_no = 1;
get_goods_list(_arguments, {'cat_id':$stateParams.cat_id, 'page_no':page_no, 'page_size':page_size},function(res){
page_total = res.pager.total;
});
}); $scope.doRefresh = function(){
page_no = 1;
get_goods_list(_arguments, {'cat_id':$stateParams.cat_id, 'page_no':page_no, 'page_size':page_size},function(){
$scope.$broadcast('scroll.refreshComplete');
});
}; $scope.loadMore = function(){
page_no += 1;
get_goods_list(_arguments, {'cat_id':$stateParams.cat_id, 'page_no':page_no, 'page_size':page_size},function(){
$scope.$broadcast('scroll.infiniteScrollComplete');
});
};
}])

ionic 下拉刷新,上拉加载更多的更多相关文章

  1. SwipeRefreshLayout实现下拉刷新上滑加载

    1. 效果图 2.RefreshLayout.java package myapplication.com.myapplication; import android.content.Context; ...

  2. Android 下拉刷新上啦加载SmartRefreshLayout + RecyclerView

    在弄android刷新的时候,可算是耗费了一番功夫,最后发觉有现成的控件,并且非常好用,这里记录一下. 原文是 https://blog.csdn.net/huangxin112/article/de ...

  3. juery下拉刷新,div加载更多元素并添加点击事件(二)

    buffer.append("<div class='col-xs-3 "+companyId+"' style='padding-left: 10px; padd ...

  4. 移动端下拉刷新上拉加载-mescroll.js插件

    最近无意间看到有这么一个上拉刷新下拉加载的插件 -- mescroll.js,个人感觉挺好用的,官网地址是:http://www.mescroll.com 然后我就看了一下文档,简单的写了一个小dem ...

  5. Android如何定制一个下拉刷新,上滑加载更多的容器

    前言 下拉刷新和上滑加载更多,是一种比较常用的列表数据交互方式. android提供了原生的下拉刷新容器 SwipeRefreshLayout,可惜样式不能定制. 于是打算自己实现一个专用的.但是下拉 ...

  6. Android 自定义 ListView 上下拉动“刷新最新”和“加载更多”歌曲列表

    本文内容 环境 测试数据 项目结构 演示 参考资料 本文演示,上拉刷新最新的歌曲列表,和下拉加载更多的歌曲列表.所谓"刷新最新"和"加载更多"是指日期.演示代码 ...

  7. [ionic开源项目教程] - 第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll

    第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll 1.将tab1.html的代码改为如下: <ion-content> <ion-ref ...

  8. 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载

    title: 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载 tags: -RecyclerView,下拉刷新,上拉加载更多 grammar_cjkRuby: true - ...

  9. ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多

    ListView实现Item上下拖动交换位置  并且实现下拉刷新  上拉加载更多 package com.example.ListViewDragItem; import android.app.Ac ...

  10. JS+CSS实现的下拉刷新/上拉加载插件

    闲来无事,写了一个当下比较常见的下拉刷新/上拉加载的jquery插件,代码记录在这里,有兴趣将代码写成插件与npm包可以留言. 体验地址:http://owenliang.github.io/pull ...

随机推荐

  1. Activiti初学者教程 (zhuan)

    http://blog.csdn.NET/bluejoe2000/article/details/39521405 ****************************************** ...

  2. response.setContentType 与response.setCharacterEncoding

    response.setContentType  设置发送到客户端的响应的内容类型,可以包括字符编码说明.  也就是说在服务器端坐了这个设置,那么他将在浏览器端起到作用,在你打开浏览器时决定编码方式 ...

  3. python学习笔记(21)--新建html乱码(给每本漫画生成一个html)

    说明: 1. open("index.html","w",encoding="utf-8"),open的第三个参数可以设置编码格式. 2. ...

  4. C++笔记 5

    C++笔记     第十四天         2007年4月10日                        1.对文件的分类  (1)文本文件:每个字节都是有效的可显示的ASCII码 ,getl ...

  5. WEB只能输入固定的字符

    <head runat="server"> <title></title> <script type="text/javascr ...

  6. oozie中使用sqoop导入hive表时提示hive找不到

    根据出错信息是找不到hive的位置,所以想到的解决方法是: 在sqoop的workflow中添加job-xml,属性写hive-site.xml在hdfs上的位置. (fail) 直接配置一个hive ...

  7. excel导出功能优化

    先说说优化前,怎么做EXCEL导出功能的: 1. 先定义一个VO类,类中的字段按照EXCEL的顺序定义,并且该类只能用于EXCEL导出使用,不能随便修改. 2. 将查询到的结果集循环写入到这个VO类中 ...

  8. CentOs6.5 安装rabbitmq(转)

    // 安装预环境 yum install gcc gcc-c++ yum install zlib zlin-devel ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 / ...

  9. http抓包工具

    fiddler 可以用该工具抓包并修改对应的参数数据

  10. Restful --- 让JSON回归单纯

    设计模式才是软件哲学的根本.. 一种软件架构风格.设计风格,而不是标准,只是提供了一组设计原则和约束条件.它主要用于客户端和服务器交互类的软件.基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓 ...