为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

holdtom 2021-08-20 17:00:40
我有一个 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;      }
查看完整描述

1 回答

?
暮色呼如

TA贡献1853条经验 获得超9个赞

尝试更改模板片段


<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时它仍然没有定义


查看完整回答
反对 回复 2021-08-20
  • 1 回答
  • 0 关注
  • 173 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信