Commit 5b022456 authored by Sam Saccone's avatar Sam Saccone

Merge pull request #1512 from davidrunger/angular-filter

angularjs: simplify clearCompleted method
parents 44053122 e856cd47
......@@ -36,14 +36,8 @@ angular.module('todomvc')
clearCompleted: function () {
var originalTodos = store.todos.slice(0);
var completeTodos = [];
var incompleteTodos = [];
store.todos.forEach(function (todo) {
if (todo.completed) {
completeTodos.push(todo);
} else {
incompleteTodos.push(todo);
}
var incompleteTodos = store.todos.filter(function (todo) {
return !todo.completed;
});
angular.copy(incompleteTodos, store.todos);
......@@ -112,14 +106,8 @@ angular.module('todomvc')
clearCompleted: function () {
var deferred = $q.defer();
var completeTodos = [];
var incompleteTodos = [];
store.todos.forEach(function (todo) {
if (todo.completed) {
completeTodos.push(todo);
} else {
incompleteTodos.push(todo);
}
var incompleteTodos = store.todos.filter(function (todo) {
return !todo.completed;
});
angular.copy(incompleteTodos, store.todos);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment