There are times when I need to exit from my $scope function based on a certain condition. I have attempted to achieve this using the return statement. However, my efforts have been in vain as it only exits from the current loop and not from the main scope function. Despite the value of d.xyz being true, the f2 function is still being called. My goal is to exit from f1 if the xyz property of d evaluates to true.
$scope.f1 = function(){
angular.foreach(data, function(d){
if(d.xyz){
return; // also tried with return false
}
if(d.abc){
//some code
}
$scope.f2();
})
}