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

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