Since there is no gap option for ngFor, you can try an alternative way.
This method does not actually break the loop, but skips the next element to display / start after a certain condition is satisfied whether the next element is false.
In page.html
<div class="loop-div" *ngFor="let element of array"> <div class="check-div" *ngIf="displayCondition(checkValue, element.value)" > {{displayValue}} </div> </div>
In page.ts
checkSameValue; //initialised before constructor displayCondition(checkValue, elementValue) { if(this.checkSameValue && this.checkSameValue == checkValue) { return false; } if(checkValue == elementValue) { this.checkSameValue = checkValue; return true; } }
This specific code avoids the further .check-div for display, even if the condition is met. then after the condition is met, the loop is not displayed until checkValue is checkValue .
source share