Тем не менее я получил ниже ошибку: Тип Ошибка Не удается прочитать свойство 'length', подключен к html-строке 9:
Test
</mat-header-cell>
<mat-cell fxFlex="40%" mat-cell *matCellDef="let row; let element"
line 9: [ngStyle]="checkIfTrue(element.name) && {'background-color':'lightgreen'}">
<mat-checkbox [ngStyle]="checkIfTrue(element.name) && {'background-color':'white'}" (click)="$event.stopPropagation()" (change)="$event ? selection.toggle(row) : null" [checked]="selection.isSelected(row)">
</mat-checkbox>
</mat-cell>
</ng-container>
И checkIfTrue из компонента:
checkIfTrue(name?: string) {
if (name) {
if (!this.isLoadingArray[this.groupName]) {
for (const team of this.teams) {
if (name === team.teamPromotion1 || name === team.teamPromotion2) {
return true;
} else {
return false;
}
}
}
} else {
return false;
}
}
Я думаю, все значения были инициализированы.