Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 对函数没有任何反应_Angular_Typescript_Ng Class - Fatal编程技术网

Angular 对函数没有任何反应

Angular 对函数没有任何反应,angular,typescript,ng-class,Angular,Typescript,Ng Class,我在NgClass中使用了一个函数,该函数使用ngOnInit填充的数组 ngOnInit->prepareRezerwation()createcolorrezwationveriable: this.nodeService.getRezerwations(this.minMax).subscribe(rezerwations => { this.prepareRezerwation(rezerwations); // this.functionsServi

我在NgClass中使用了一个函数,该函数使用ngOnInit填充的数组

ngOnInit->prepareRezerwation()createcolorrezwationveriable:

    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(colIndex, rowIndex){
    this.colorRezerwation.position.forEach(arrayItem => {
      if(arrayItem.column === colIndex && arrayItem.row === rowIndex){
        return {'reservation': true}
      } 
    });
  }
当我跳过整个forEach返回时,它工作正常


感谢您提供的所有帮助。

您正在将函数中的类变量返回到forEach循环,而不是setColor函数

setColor(colIndex,rowIndex){
this.colorRezerwation.position.forEach(arrayItem=>{
if(arrayItem.column==colIndex&&arrayItem.row==rowIndex){
-->返回{'reservation':true}{
if(arrayItem.column==colIndex&&arrayItem.row==rowIndex){
类={'reservation':true}
} 
});
返回舱;
}