Data are not showing when two api called in` iondi

2019-03-06 13:43发布

问题:

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();
  }



}