Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 9370113

Browse files
Samuli Ulmanenwardbell
Samuli Ulmanen
authored andcommitted
docs(todo app): replace remaining tasks reduce func with filter.length
closes #1050
1 parent 2b714a3 commit 9370113

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

public/docs/_examples/homepage-todo/ts/app/todo_app.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// #docregion
22
import {Component} from 'angular2/core';
3-
import {Todo} from './todo';
4-
import {TodoList} from './todo_list';
5-
import {TodoForm} from './todo_form';
3+
import {Todo} from './todo';
4+
import {TodoList} from './todo_list';
5+
import {TodoForm} from './todo_form';
66

77
@Component({
88
selector: 'todo-app',
@@ -18,19 +18,19 @@ import {TodoForm} from './todo_form';
1818
})
1919
export class TodoApp {
2020
todos: Todo[] = [
21-
{text:'learn angular', done:true},
22-
{text:'build an angular app', done:false}
21+
{text: 'learn angular', done: true},
22+
{text: 'build an angular app', done: false}
2323
];
2424

2525
get remaining() {
26-
return this.todos.reduce((count: number, todo: Todo) => count + +!todo.done, 0);
26+
return this.todos.filter(todo => !todo.done).length;
2727
}
2828

2929
archive(): void {
30-
var oldTodos = this.todos;
30+
let oldTodos = this.todos;
3131
this.todos = [];
32-
oldTodos.forEach((todo: Todo) => {
33-
if (!todo.done) this.todos.push(todo);
32+
oldTodos.forEach(todo => {
33+
if (!todo.done) { this.todos.push(todo); }
3434
});
3535
}
3636

0 commit comments

Comments
 (0)