I have an if statement but need it to "break" if the first condition is met but AFTER I have completed some processes. The if statement is wrapped inside a forEach statement in Angular.
angular.forEach($scope.obj, function ( value, key) {
if( id == key) {
delete $scope.obj[id];
result.clicked = false;
//break here, don't run the else
} else {
$scope.obj[id] = result;
result.clicked = true;
}
})
returnorbreakangular.foreachand the reason why is explained here. You can try something like what is explained in the top answer of How to short circuit Array.forEach like calling break?