I have an array like this:
$scope.emails = [
{\"key\":\"Work\",\"value\":\"user@domine.com\"},
{\"key\":\"\",\"value\":\"\"},
{\"key\":\"Work\",\"value\":
Like others have pointed out, the culprit of the code is the array got removed. To get around with angular.forEach, you can try the additive/assignment approach:
var filteredEmails = [];
angular.forEach($scope.emails, function(email, index){
if(email.value !==""){
filteredEmails.push(email);
}
});
$scope.emails = filteredEmails;