Я использую функцию в NgClass, которая использует массив, заполненный в ngOnInit.
ngOnInit -> prepareRezerwation () create colorRezerwation проверяемый:
this.nodeService.getRezerwations(this.minMax).subscribe(rezerwations => {
this.prepareRezerwation(rezerwations);
// this.functionsService.showRezerwation(post, this.openingHours);
// this.showSpinner = false;
}, error => {
console.log("Connection problem")
});
html -> [ngClass] = "setColor (1, i):
<ng-container matColumnDef="big">
<th mat-header-cell *matHeaderCellDef class="xunk-calendar-cell"></th>
<td mat-cell *matCellDef="let element; let i = index" [ngClass]="setColor(1,i)">Name</td>
</ng-container>
setColor (1, i):
setColor(colIndex, rowIndex){
this.colorRezerwation.position.forEach(arrayItem => {
if(arrayItem.column === colIndex && arrayItem.row === rowIndex){
return {'reservation': true}
}
});
}
Когда я пропускаю весь возврат forEach, он работает нормально.
Спасибо за помощь.