ionic 下拉刷新,上拉加载更多
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 下拉刷新,上拉加载更多的更多相关文章
- SwipeRefreshLayout实现下拉刷新上滑加载
1. 效果图 2.RefreshLayout.java package myapplication.com.myapplication; import android.content.Context; ...
- Android 下拉刷新上啦加载SmartRefreshLayout + RecyclerView
在弄android刷新的时候,可算是耗费了一番功夫,最后发觉有现成的控件,并且非常好用,这里记录一下. 原文是 https://blog.csdn.net/huangxin112/article/de ...
- juery下拉刷新,div加载更多元素并添加点击事件(二)
buffer.append("<div class='col-xs-3 "+companyId+"' style='padding-left: 10px; padd ...
- 移动端下拉刷新上拉加载-mescroll.js插件
最近无意间看到有这么一个上拉刷新下拉加载的插件 -- mescroll.js,个人感觉挺好用的,官网地址是:http://www.mescroll.com 然后我就看了一下文档,简单的写了一个小dem ...
- Android如何定制一个下拉刷新,上滑加载更多的容器
前言 下拉刷新和上滑加载更多,是一种比较常用的列表数据交互方式. android提供了原生的下拉刷新容器 SwipeRefreshLayout,可惜样式不能定制. 于是打算自己实现一个专用的.但是下拉 ...
- Android 自定义 ListView 上下拉动“刷新最新”和“加载更多”歌曲列表
本文内容 环境 测试数据 项目结构 演示 参考资料 本文演示,上拉刷新最新的歌曲列表,和下拉加载更多的歌曲列表.所谓"刷新最新"和"加载更多"是指日期.演示代码 ...
- [ionic开源项目教程] - 第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll
第7讲 实现下拉刷新上拉加载ion-refresher和ion-infinite-scroll 1.将tab1.html的代码改为如下: <ion-content> <ion-ref ...
- 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载
title: 带你实现开发者头条APP(五)--RecyclerView下拉刷新上拉加载 tags: -RecyclerView,下拉刷新,上拉加载更多 grammar_cjkRuby: true - ...
- ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多
ListView实现Item上下拖动交换位置 并且实现下拉刷新 上拉加载更多 package com.example.ListViewDragItem; import android.app.Ac ...
- JS+CSS实现的下拉刷新/上拉加载插件
闲来无事,写了一个当下比较常见的下拉刷新/上拉加载的jquery插件,代码记录在这里,有兴趣将代码写成插件与npm包可以留言. 体验地址:http://owenliang.github.io/pull ...
随机推荐
- 搞清tomcat中的编解码
http://www.xuebuyuan.com/1287083.html *********************************** 经常会被乱码问题搅得头晕脑胀.事实上,乱码问题涉及的 ...
- 内存单元,CPU对存储器的读写,三大总线
.存储单元 存储器被分成若干个存储单元,每个存储单元从0开始顺序编号.电子计算机的最小信息单位是bit.8个bit组成一个Byte(虽然现在一个字节可能不是8位,有宽字符出现了,但是一般我们的机器都是 ...
- 基于html5鼠标悬停图片动画展示效果
分享一款基于html5鼠标悬停图片动画展示效果.里面包含两款不同效果的html5图片展示效果.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class=" ...
- 大数据之ETL工具Kettle的--1功能介绍
Kettle是一款国外开源的ETL工具,纯java编写,可以在Window.Linux.Unix上运行. 说白了就是,很有必要去理解一般ETL工具必备的特性和功能,这样才更好的掌握Kettle的使用. ...
- cocos2dx遇到的坑2
记录下在cocos2dx 2.x时代遇到的问题 1.cocos2dx retain 在onenter时,在onexit时 release 2.先结束定时器再退出界面 3.在不同帧里数据是有可能不一 ...
- WPF ListBoxItem DataTempldate command 执行问题
今天用到MVVM,在listboxItem中做command处理.因为是要获取数据,修改ListBox模板,但是发现command无法正确执行,写在Item中可以正确执行. 网上也遇到类似问题,但是没 ...
- Win10系统设置专用网络和公用网络
打开设置界面或者按Win+I组合键打开设置界面,打开后点击“网络和Internet”; 在网络和Internet界面,点击左侧“拔号”(有些是以太网),在右侧窗口点击“宽带连接”(大家基本都是以太网连 ...
- 各种api接口
实用号码归属地查询(IP 地址,手机号码): 默认格式: http://api.liqwei.com/location/ (使用来访者的 IP 地址) 指定 IP 地址格式: http://api.l ...
- thinkphp 前台测试
配置文件 <?php return array( 'DB_TYPE' => 'mysql', // 数据库类型 'DB_HOST' => 'localhost', // 服务器地址 ...
- android NavigationBar 显示
android连接7inch屏时,虚拟按键会显示到右侧,变成一条黑边,并且只有back功能. 在连接10inch的时候,虚拟按键就正常,显示在屏幕的底部.有back,home,recent app三个 ...