docs(todo app): replace remaining tasks reduce func with filter.length

closes #1050
This commit is contained in:
Samuli Ulmanen 2016-04-06 09:10:52 +03:00 committed by Ward Bell
parent 2b714a3945
commit 9370113b9d
1 changed files with 9 additions and 9 deletions

View File

@ -18,19 +18,19 @@ import {TodoForm} from './todo_form';
}) })
export class TodoApp { export class TodoApp {
todos: Todo[] = [ todos: Todo[] = [
{text:'learn angular', done:true}, {text: 'learn angular', done: true},
{text:'build an angular app', done:false} {text: 'build an angular app', done: false}
]; ];
get remaining() { get remaining() {
return this.todos.reduce((count: number, todo: Todo) => count + +!todo.done, 0); return this.todos.filter(todo => !todo.done).length;
} }
archive(): void { archive(): void {
var oldTodos = this.todos; let oldTodos = this.todos;
this.todos = []; this.todos = [];
oldTodos.forEach((todo: Todo) => { oldTodos.forEach(todo => {
if (!todo.done) this.todos.push(todo); if (!todo.done) { this.todos.push(todo); }
}); });
} }