为什么我从URL得到一些空数组

时间:2019-02-11 13:29:25

标签: angular ionic4

我正在从URL获取数据json。一切工作正常,但问题是有时我没有从URL获得所有数据json数组,即使它存在。我的数据数组json大约是60到70,但是我只有15到20个元素。

here is my app showing t you only some element and the rest is empty

我的代码:

 async getData() {


  const loading = await this.loadingController.create({
    message: 'Loading'
  });
  await loading.present();


  this.http.get('/airport.json?code=krt', {}, {})
  .then(data => {

    this.test = JSON.parse(data.data);
    const parsed = JSON.parse(data.data);
    this.items = parsed.response.airport.schedule.arrival.data;
    loading.dismiss()




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



}

html:

 <ion-item *ngFor="let item of items"  routerDirection="forward" > 
        <table>
            <tbody>
            <tr >
            <td > 
                <img src="operators/{{item?.airline.code.icao}}_logo0.png"  (error)="handleImgError($event, item)" class="img-logo">
              </td>
            <td text-left>{{item?.identification.number.default}}</td>
            <td text-center>{{item?.airport.region.city}}</td>
            <td text-right>{{item?.time.scheduled.arrival  * 1000 | date:"h:mma"}}</td>
            </tr>
            <tr >
            <td >&nbsp;</td>
            <td ></td>
            <td text-center>{{item?.aircraft.model.code}}</td>
            <td text-right>{{item?.status.generic.status.text}}</td>
            </tr>
            </tbody>
            </table>
      </ion-item>

有时我的某些数据为空! 。我如何避免null?有什么解决办法吗?

0 个答案:

没有答案