错误类型错误:无法读取 Object.updateDirectives 处未定义的属性“长度”

我有一个 angular 8 应用程序。如果加载了某个组件,我会收到一个错误


无法读取未定义的属性“长度”


我在谷歌上搜索了很多并做了一些教程。但是我不知道如何处理这个错误。


所以如果我加载这个组件:


import { Component, OnInit } from '@angular/core';

import { HealthAPIService } from '../../shared/health-api/health-api.service';


import { DossierEntry } from '../../interfaces/dossier/dossier-entry.interface';


@Component({

  selector: 'app-dossier-correspondence',

  templateUrl: './dossier-correspondence.component.html',

})


export class DossierCorrespondenceComponent implements OnInit {

  allCorrespondence: Array<DossierEntry>;

  correspondenceEntries: Array<DossierEntry>;

  attachmentEntries: Array<DossierEntry>;

  message = '';

  emptyMessage = 'Geen correspondentie.';

  errorMessage = 'Er ging iets mis met de connectie. Probeer over enkele minuten nogmaals.';


  correspondenceLoaded = false;

  showingSingle = false;


  single: DossierEntry;


  constructor(private healthAPIService: HealthAPIService) {}


  handleCorrespondenceLoad(result) {

    if (result &&  result.length === 0) {

      this.message = this.emptyMessage;

      return;

    }

    this.allCorrespondence = result;

    this.attachmentEntries = [];

    this.correspondenceEntries = [];

    for (let entry of result) {

      switch (entry.type) {

        case 'correspondence': {

          this.correspondenceEntries.push(entry);

          break;

        }

        case 'attachments': {

          this.attachmentEntries.push(entry);

          break;

        }

        default: {

          console.log('Dossier correspondence heeft een invalide entry soort teruggegeven');

          break;

        }

      }

    }

  }


  gotoItem(index, type: string) {

    this.showingSingle = true;

    // this.single = this.allCorrespondence[index];

    switch (type) {

      case 'correspondence': {

        this.single = this.correspondenceEntries[index];

        break;

      }

      case 'attachments': {

        this.single = this.attachmentEntries[index];

        break;

      }



holdtom
浏览 174回答 1
1回答

暮色呼如

尝试更改模板片段<app-is-loading *ngIf="!correspondenceLoaded" message="Correspondentie wordt geladen"></app-is-loading><div *ngIf="!showingSingle && correspondenceEntries.length > 0">到<app-is-loading *ngIf="!correspondenceLoaded" message="Correspondentie wordt geladen"></app-is-loading><div *ngIf="!showingSingle && correspondenceEntries && correspondenceEntries.length > 0">似乎您正在尝试访问correspondenceEntries.length时它仍然没有定义
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript