我有一个 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;
}
暮色呼如
相关分类