Earlier today, I encountered an unusual issue while working on an Angular application.
We initialized an Array in the component.ts file during ngInit like this:
for(let i = 0; i < 1; i++) {
this.cluster[i] = [];
for(let j = 0; j < 3; j++) {
this.cluster[i][j] = false;
}
}
In the component.html file, we utilized a for loop to go through the Array:
<div *ngFor="let col of cluster; let iCol = index" class="col-sm-4 offset-sm-2 col-md-4 offset-md-0">
<div *ngFor="let row of col; let iRow = index">
<div*ngIf="(cluster.length < 2 && cluster[0].length < 4)">
<p>Test</p>
</div>
</div>
</div>
According to my understanding, there should be 3 instances of "Test"
, but we only see one.
Could someone provide insight into where the error might be occurring? Thank you in advance!