Goal: I want to change the text to red based on a condition, when looping through an object (using ngClass in Angular 6)
This was working for me, but all of a sudden is no longer working.
I've tried printing to console... and I am getting In Progress false Complete true
(Expected) Which makes me think the first one should be red, and the second one black. (Actual) But they are both black.
I've also tried resetting the variable isComplete back to false if it got to the else condition. Angular: conditional class with *ngClass
HTML:
<div class="row" *ngFor="let lesson of lessons">
<div>
<div class="flex">
<div>
Status: <span [ngClass]="(isComplete!=true)?'text-red':''">{{ lesson.Status }}</span>
</div>
</div>
</div>
</div>
TypeScript:
private isComplete: boolean = false;
this.lessons.forEach(element => {
if (element.Status == "Complete") {
this.isComplete = true;
element.Status = this.var1;
}
else {
element.Status = this.var2;
}
});