Data are not showing when two api called in` iondidenter`

荒凉一梦 提交于 2019-12-20 05:47:16

问题


I have one screen, which have two gridview . each grid view will populate some value after api calling. so my page will have 2 api calling. so when i call my api call method under constructor or ionViewDidEnter its not working. it allowing only one method to exeute.

here is my two api call method on one page .ts

Even i put under my constructor. But its not showing the data. so if i want to call the both api and need to display the data means how can i do that.please help me out. i was not able to find it out !!

Thanks in advance

updated:

import { Component, ViewChild } from '@angular/core';
import { AlertController, App, FabContainer, ItemSliding, List, ModalController, NavController, ToastController, LoadingController, Refresher } from 'ionic-angular';
import { CategoryDetailPage } from '../categorydetail/categorydetail';
import { ConferenceData } from '../../providers/conference-data';
import { UserData } from '../../providers/user-data';
import { SessionDetailPage } from '../session-detail/session-detail';
import { ScheduleFilterPage } from '../schedule-filter/schedule-filter';
import {Http, Headers } from '@angular/http';
import 'rxjs/add/operator/map';
import { AuthService } from '../../providers/AuthService';

@Component({
  selector: 'page-speaker-list',
  templateUrl: 'speaker-list.html'
})
export class SpeakerListPage {
loading: any;

   data: any;
   Catdata: any;
   Catdatanames: any;


    resdata: any;
   resCatdata: any;
   resCatdatanames: any;


   loginData: {username?: string} = {};
   resloginData: {username?: string} = {};


  constructor(
     public alertCtrl: AlertController,
    public app: App,
    public loadingCtrl: LoadingController,
    public modalCtrl: ModalController,
    public navCtrl: NavController,
    public toastCtrl: ToastController,
    public confData: ConferenceData,
    public user: UserData,
    public http:Http,
    public authService: AuthService
  ) { 


  }

  ionViewDidEnter() {
  this.show(); 
  this.another();
  }


show() {
  this.showLoader();

    this.authService.subs(this.loginData).then((result) => {
      this.loading.dismiss();
      this.data = result;

       if(this.data.status == 1)
       {
       this.Catdata = this.data.SubjectList;

       //this.Catdata.forEach(category => console.log(category.CatID));

      for(let i=0; i<this.Catdata.length; i++) {
              // console.log(this.Catdata[i].SubjectName);
           } 

       }

       else if(this.data.status == 0) {

     let alert = this.alertCtrl.create({
    title: 'Error',
    subTitle: 'Please Enter Valid Username & Password',
    buttons: ['OK']
  });
  alert.present();
       }

    }, (err) => {
      this.loading.dismiss();

    });
}


another() {

    this.authService.allresources(this.resloginData).then((result) => {


      this.resdata = result;

       if(this.resdata.status == 1)
       {
       this.resCatdata = this.resdata.SubjectList;
           for(let i=0; i<this.resCatdata.length; i++) {
              // console.log(this.resCatdata[i].FileName);
           }



       }

       else if(this.resdata.status == 0) {

     let alert = this.alertCtrl.create({
    title: 'Error',
    subTitle: 'Please Enter Valid Username & Password',
    buttons: ['OK']
  });
  alert.present();
       }

    }, (err) => {


    });
}

showLoader(){
    this.loading = this.loadingCtrl.create({
        content: 'Authenticating...'
    });

    this.loading.present();
  }



}

来源:https://stackoverflow.com/questions/43819687/data-are-not-showing-when-two-api-called-in-iondidenter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!