My ngFor is not showing all the data that arrives, but in the console it shows all the results.
I get some data from the API and it has a sales data and a meta data, they come in an array and I use the forEach in them, and if it hits the target it should go to another array:
this.MetaService.FiliaisMetaDiarias().subscribe(
data => {
const response = (data as any)
this.objeto_retorno = JSON.parse(response._body);
this.objeto_retorno.forEach(element => {
this.tots = element.TOTAL
if (this.tots >= this.MetaAtingida) {
this.fil = [
{
FI: element.FILIAL,
porc: element.TOTAL
}
]
this.fil.forEach(elements => {
this.mainColor = 'MetaAtingida'
})
}
Then I play html:
<p [class]="mainColor + ' teste'" *ngFor="let elements of fil" >Filial {{ elements.FI }} = {{ elements.porc }}</p>
It should show all results, but for some reason is showing only the last data, but in the console it shows all the data.
Can anyone help me?