83
rated 0 times
[
87]
[
4]
/ answers: 1 / hits: 21400
/ 11 Years ago, sun, june 2, 2013, 12:00:00
$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.
More From » angularjs