Want to change background color of cell based on value of variable in mat table angular

47 views Asked by At

I am using angular material and in that using mat-table.

Now I want to change background color of cell based on value of variable.

So if value is >50 then it should show yellow color OR show green color.

Below I am attaching image in that in second column I want to apply that changes.

enter image description here

Below is my code which I am trying..

<ng-container matColumnDef="status">
                  <mat-header-cell *matHeaderCellDef>
                  </mat-header-cell>
                  <mat-cell
                    *matCellDef="let element; let i = index"
                    [formGroupName]="i"
                  >
                    <mat-form-field
                      [ngClass]="{ 'yellow': isTrue && i==0, 'red': !isTrue && i==0  }"
                    >
                      <input
                        matInput
                        type="text"
                        placeholder="0" 
                      />
                    </mat-form-field>
                  </mat-cell>
                </ng-container>
0

There are 0 answers