2
I have an html with ngFor:
<div class="row p-3 border-bottom" *ngFor="let cont of contrib">
<!-- ! -->
<div class="col">
<p [class.text-danger]="redName === true" [class.text-light]="redName === false">{{cont.NOME}}</p>
</div>
<!-- ! -->
</div>
I make a request to see if this count.NAME has data in the database, if it does not have, the name will be in the text-light class, but if it has data, it will be in text-Danger:
for (let index = 0; index < colabs.length; index++) {
this.service.showResults(colabs[index].FILIAL, colabs[index].MATRICULA).subscribe(
(res) => {
let cont = (<any>res).length
if (cont > 0) {
//nome fica vermelho
this.redName = true;
} else {
this.redName = false;
}
},
(err) => console.log(err)
)
}
but the names are only getting the text-Danger class, and one of them should stick with text-light. Someone could help me?
gave error: ERROR Error: Uncaught (in Promise): Error: Template parse errors: Parser Error: Missing expected : at column 10 in [{redName == true ? 'text-Danger' : 'text-light'}]
– Maria
edited the answer in case of error let me know
– OtavioCapel
did not give error, but did not change the color
– Maria