The Console is showing an error:
ERROR TypeError: Cannot read properties of undefined (reading 'data")
at Oviewer Component 15A11Selected (oviewer.component.ts:97:37)
at OviewerComponent.checkbeaLabel (aviewer.component.ts:114:22)
at Oviewer Component th 26 Template (oviewer.component.html:79:68)
File: Oviewer.component.html
<div class="stable mat-elevation-z8">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
<!-- Checkbox Column -->
<ng-container matColumnDef="select">
<th mat-header-cell *matHeaderCellDef>
<mat-checkbox
(change)="$event? toggleAllRows(): null" color="primary"
[checked]="selection.hasValue() && isAllSelected()"
[indeterminate]-"selection.hasValue() && lisAllSelected()"
[aria-label]="checkboxLabel()"
</mat-checkbox>
File: Oviewer.component.ts
iSAllSelected() {
const numSelected =this.selection.selected.length;
const numRows =this.dataSource.data.length;
return numSelected === numRows;
/** Selects all rows if they are not all selected; otherwise clear selection.*/
toggleAllRows() {
if (this.isAllSelected())
{
this.selection.clear();
return;
}
this.selection.select(...this.dataSource.data);
}
/** The label for the checkbox on the passed row */
checkboxLabel(row?: any): string { if (!row) { return ${this.isAllSelected() ? 'deselect' : 'select') all';
}
I am having trouble finding a solution for this issue. Can someone please assist me in understanding why I am encountering this Console error?