I want to add a class with condition but it is not working
<tr *ngFor="let time of times; let i = index">
<td [ngClass]="{'red-time':checkInvalid(time['Proles Arrive'])}">{{time['Proles Arrive']}}</td>
</tr>
This is in my HTML
checkInvalid(entry: string){
console.log("This is the entry:" + entry);
return entry === 'Invalid Entry';
}
But the class is never added, even though when i log the entry it says "Invalid Entry"
Even when i use "[ngClass]="{'red-time':true}" its still not adding the class.
Any suggestions please?
更改条件如下
<td [ngClass]="{'red-time':checkInvalid(time['Proles Arrive'])==true}">{{time['Proles Arrive']}}</td>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.