在Angular 2中打破NgFor循环 [英] Break NgFor Loop in Angular 2

查看:56
本文介绍了在Angular 2中打破NgFor循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在模板内使用*ngFor迭代数组,并使用* ngIf搜索基于键的元素.现在,当条件与键匹配时,我想破坏*ngFor.我想知道angular2中是否有任何选项可以根据条件中断ngFor循环.

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.

推荐答案

没有任何选择可以破坏ngFor.您可以使用自定义管道,该管道在满足条件的元素之后不返回值.

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.

这篇关于在Angular 2中打破NgFor循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆