$scope.clearCompleted = function()
{
angular.forEach($scope.todos, function(todo, i)
{
if(todo.done)
{
$scope.todos.splice(i, 1);
}
});
if($scope.todos.length == 0)
{
$scope.isEmpty = true;
}
}
This is my code to delete the 'done' todos from an array, but when two todos after each other are removed, it only removes the second. I think it's because the splice function resets and the returns the spliced array.
.splice()mutates an Array. This needs to be accounted for if using a forward iteration.