I have a grid and I want to sending class condition from .ts file. I achieve this with code myClassCondition = 5 < 6 ? 'bg-red' : null; like below. But, I want like below with "col" and "rowData". Is gave me compilation error because there is no "col" and "rowData" in .ts file. How can I achieve this?
<ng-template pTemplate="body" let-rowData>
<tr>
<td *ngFor="let col of myColumns" class="ui-resizable-column">
<span [ngClass]="myClassCondition"> {{rowData[col.field]}}</span>
</td>
</tr>
</ng-template>
This working perfectly.
myClassCondition = 5 < 6 ? 'bg-red' : null;
But I want like this.
myClassCondition = col.field == 'studentAge' && rowData.[col.field] < 6 ? 'bg-red' : null;
I tried this but also not worked.
myClassCondition : string = "col.field == 'studentAge' && rowData.[col.field] < 6 ? 'bg-red' : null";
col.field != 'studentAge'?colandrowDataparameter instead of the string propertymyClassCondition(which btw. isn't a condition but just a string value).