角JS休息的ForEach [英] Angular JS break ForEach
本文介绍了角JS休息的ForEach的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个角foreach循环,我想从回路断线,如果我一个值相匹配。下面code不起作用。
I have an angular foreach loop and i want to break from loop if i match a value. The following code does not work.
angular.forEach([0,1,2], function(count){
if(count == 1){
break;
}
});
我怎样才能得到呢?
How can i get this?
推荐答案
有没有办法做到这一点。见<一href=\"https://github.com/angular/angular.js/issues/263\">https://github.com/angular/angular.js/issues/263.根据你正在做的,你可以使用一个布尔值,只是不会进入循环体的。是这样的:
There's no way to do this. See https://github.com/angular/angular.js/issues/263. Depending on what you're doing you can use a boolean to just not going into the body of the loop. Something like:
var keepGoing = true;
angular.forEach([0,1,2], function(count){
if(keepGoing) {
if(count == 1){
keepGoing = false;
}
}
});
这篇关于角JS休息的ForEach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文