Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Break NgFor Loop in Angular 2

Tags:

angular

I am trying to iterate array using *ngFor inside the template and searching for an element based on the key, using *ngIf. Now when the condition is matched with the key I want to break the *ngFor. I wondered if there any option in angular2 to break the ngFor loop based on condition.

like image 527
deen Avatar asked Oct 07 '16 06:10

deen


1 Answers

There is no option to break ngFor. You can use a custom pipe that doesn't return values after the element where the condition is met.

For more concrete approaches please provide more concrete information about what you actually try to accomplish.

like image 149
Günter Zöchbauer Avatar answered Sep 30 '22 23:09

Günter Zöchbauer