我想停止对getModelData
ifshouldPermit
的重复调用true
。但下面的代码总是在控制台中打印why I got printed forEach newlySelectedUsers
每个newlySelectedUsers
.
var shouldPermit = false;
angular.forEach(newlySelectedUsers, function(value, key) {
if(!shouldPermit) {
console.log("why I got printed forEach newlySelectedUsers")
userService.getModelData($scope.$root.test[value].id)
.success(function (data) {
if(lodash.isEmpty(data)) {
shouldPermit = true;
$scope.insertSaving();
}
});
}
});
如何停止调用getModelData
一次shouldPermit
成为真的?