I am getting an undefined value in an array I've set up when I console.log it.
Below is my component.ts:
export class OrderExceptionReportComponent implements OnInit {
public sessionData: ExceptionReportSessionData[] = [];
newData: any;
reports = [];
constructor(private orderExceptionReportService: OrderExceptionReportService) {
}
public async getExceptionReportSessionData(): Promise<void> {
return this.orderExceptionReportService.GetExceptionReportSessionData()
.then(
data => {
this.sessionData = data;
});
}
async ngOnInit() {
await this.getExceptionReportSessionData();
}
sessionDataChange(evt) {
const value = evt.target.value;
console.log(`session index: ${value}`);
console.log(this.sessionData);
if (isNaN(Number(value))) {
this.reports = [];
} else {
this.reports = this.sessionData[Number(value)].ReportFiles;
}
console.log(this.reports);
}
}
When I console.log(this.sessionData) I am able to see my array of data just fine. But when I console.log(this.reports) from my sessionDataChange() function it logs an undefined value. I need that value for a drop down menu I am implementing. What can I do to make sure this.reports gets assigned the correct value?
