October 2017
Intermediate to advanced
280 pages
6h 50m
English
Now, let's continue with the implementation of the application:
// ch5/todo-app/app.ts
class TodoCtrl {
todos: Todo[] = [{
label: 'Buy milk',
completed: false
}, {
label: 'Save the world',
completed: false
}];
name: string = 'John';
addTodo(label) { ... }
removeTodo(idx) { ... }
toggleCompletion(idx) { ... }
}
Here is part of the implementation of the controller associated with the template of the Todo application. Inside the class declaration, we initialized the todos property to an array with two todo items.
Now, let's update the template and render these items. Here's how this is done:
<ul> <li *ngFor="let todo of todos; let index = index" [class.completed]="todo.completed"> <input type="checkbox" ...Read now
Unlock full access