Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 如何使用页面增量多次进行相同的http调用_Ionic Framework_Ionic3 - Fatal编程技术网

Ionic framework 如何使用页面增量多次进行相同的http调用

Ionic framework 如何使用页面增量多次进行相同的http调用,ionic-framework,ionic3,Ionic Framework,Ionic3,如何在页面加载时调用同一请求5次,并使用无限滚动再次调用同一请求5次?每次currentCount都应增加1 此外,InfiniteSroll仅调用请求1次。如果我再次使用它,则不会发出任何呼叫请求 我怎样才能做到这一点 这是我的.ts文件 currentCount = 0 getUserList() { this.showLoader(); this.search.page = this.currentCount; this.authService.getData(t

如何在页面加载时调用同一请求5次,并使用无限滚动再次调用同一请求5次?每次currentCount都应增加1

此外,InfiniteSroll仅调用请求1次。如果我再次使用它,则不会发出任何呼叫请求

我怎样才能做到这一点

这是我的.ts文件

currentCount = 0

getUserList() {
    this.showLoader();
    this.search.page = this.currentCount;
    this.authService.getData(this.search, "search")
      .then((result) => {
        let yourString = typeof result == 'object' && result["_body"] ? result["_body"] : [];
        let res = yourString.substring(1, yourString.length - 1);
        this.response = JSON.parse(res);
        this.userData = JSON.parse(res).details.data
      }, (err) => {
        console.log(err);
      });
  }

  doInfinite(): Promise<any> {
    this.currentCount = this.currentCount + 1;
     return new Promise((resolve) => {
      setTimeout(() => {
        this.authService.getData(this.search, "search")
          .then((result) => {
            let yourString = typeof result == 'object' && result["_body"] ? result["_body"] : [];
            let res = yourString.substring(1, yourString.length - 1);
            this.response = JSON.parse(res);
              const newData = this.response.details.data
              console.log(newData);
              for (let i = 0; i < newData.length; i++) {
                this.userData.push(newData[i]);
              }
          }, (err) => {
            console.log(err);
          });

        console.log('Async operation has ended');
        resolve();
      }, 500);
    })
  }
currentCount=0
getUserList(){
this.showLoader();
this.search.page=this.currentCount;
this.authService.getData(this.search,“搜索”)
。然后((结果)=>{
让您的字符串=typeof result=='object'&&result[“\u body”]?result[“\u body”]:[];
设res=yourString.substring(1,yourString.length-1);
this.response=JSON.parse(res);
this.userData=JSON.parse(res).details.data
},(错误)=>{
控制台日志(err);
});
}
doInfinite():承诺{
this.currentCount=this.currentCount+1;
返回新承诺((解决)=>{
设置超时(()=>{
this.authService.getData(this.search,“搜索”)
。然后((结果)=>{
让您的字符串=typeof result=='object'&&result[“\u body”]?result[“\u body”]:[];
设res=yourString.substring(1,yourString.length-1);
this.response=JSON.parse(res);
const newData=this.response.details.data
console.log(newData);
for(设i=0;i{
控制台日志(err);
});
log('异步操作已结束');
解决();
}, 500);
})
}

尝试下面的示例代码。希望它能起作用,挽救你的一天

Html文件
<ion-content (ionScrollEnd)="logScrolling($event)">
logScrolling(event)
{
 this.book_details();
}
book_details()
{
sendData= {'name':'Test'}
this.myservice.online_service(this.funcName, sendData).subscribe(response => {
    if ( response.status === 'success' && response.data.length > 0) {
      this.bookDetails = this.bookDetails.concat(response.data);
      ++this.current_page;
}