<ion-header>
<ion-toolbar>
<ion-title>
Tab One
</ion-title>
</ion-toolbar>
</ion-header> <ion-content> <ion-list>
<ion-item *ngFor="let item of list">
<ion-label>{{item.title}}</ion-label>
</ion-item>
</ion-list> <ion-infinite-scroll threshold="10%" (ionInfinite)="loadMore($event)">
<ion-infinite-scroll-content loadingSpinner="crescent" loadingText="加载中...">
</ion-infinite-scroll-content>
</ion-infinite-scroll> <p *ngIf="!hasMore">---我是有底线的---</p> </ion-content>
import { Component } from '@angular/core';

import { HttpserviceService } from '../services/httpservice.service';

@Component({
selector: 'app-tab1',
templateUrl: 'tab1.page.html',
styleUrls: ['tab1.page.scss']
})
export class Tab1Page { public list:any[]=[]; public page:any=1; public hasMore=true; constructor(public httpService:HttpserviceService){ }
ngOnInit(): void { this.getData();
} getData(){ var api='http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page='+this.page;
this.httpService.get(api).then((response:any)=>{
console.log(response)
this.list=response.result;
++this.page;
}) }
loadMore(e){
var api='http://www.phonegap100.com/appapi.php?a=getPortalList&catid=20&page='+this.page;
this.httpService.get(api).then((response:any)=>{
console.log(response)
this.list=this.list.concat(response.result);
++this.page;
//判断下一页有没有数据
if(response.result.length<20){
e.target.disabled=true; this.hasMore=false;
}
e.target.complete(); //请求完成数据以后告诉ion-infinite-scroll更新数据
})
}
}

http服务:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class HttpserviceService { constructor(public http:HttpClient) { } get(api){ return new Promise((resolve,reject)=>{
this.http.get(api).subscribe((response)=>{ resolve(response); },(err)=>{
reject(err); })
}) }
}

最新文章

  1. Java中private、protected、public和default的区别
  2. linux下QT程序输出乱码解决方法
  3. terminal崩溃打不开的一种原因以及ubuntu下matlab权限不够的解决办法
  4. PHP获取IP地址
  5. 89C51单片机实现的流水灯
  6. 微信JSSDK与录音相关的坑
  7. PHP接口的声明与引用
  8. 【转】Android 带checkbox的listView 实现多选,全选,反选 -- 不错
  9. 关于CSS选择器的效率问题
  10. 在MVC里使用 HttpContext.Response输出内容
  11. Java NIO系列教程(六) 多路复用器Selector
  12. vue.js下载及安装配置
  13. linux命令详解之df命令
  14. 【RL-TCPnet网络教程】第30章 RL-TCPnet之SNTP网络时间获取
  15. 【CSS】按钮的禁用与可用 CSS Cursor 属性
  16. 使用CompletionService结合ExecutorService批处理调用存储过程任务实例
  17. Redis集群方案怎么做?
  18. lldb调试mysql 插件命令
  19. BDD实战篇 - .NET Core里跑Specflow - 可以跑集成测试和单元测试
  20. 845. Greatest Common Divisor

热门文章

  1. WEB前端-搜索引擎工作原理与SEO优化
  2. yarn cluster和yarn client模式区别——yarn-cluster适用于生产环境,结果存HDFS;而yarn-client适用于交互和调试,也就是希望快速地看到application的输出
  3. LG4195 【模板】exBSGS
  4. (java)selenium webdriver学习---三种等待时间方法:显式等待,隐式等待,强制等待
  5. ORM框架三种映射在Springboot上的使用
  6. windows部署tomcat
  7. vue中input输入第一个字符时,光标会消失,需要再次点击才能输入
  8. Bash基本功能:输入输出重定向
  9. loj #2053 莫队
  10. 【概率论】6-4:分布连续性修正(The Correction for Continuity)