-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodos.component.ts
More file actions
58 lines (50 loc) · 1.01 KB
/
todos.component.ts
File metadata and controls
58 lines (50 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Component, OnInit } from '@angular/core';
import { Todo } from '../models/Todo';
@Component({
selector: 'app-todos',
templateUrl: './todos.component.html',
styleUrls: ['./todos.component.css']
})
export class TodosComponent implements OnInit {
todos: Todo[] | undefined;
inputTodo:string="";
constructor() { }
ngOnInit(): void {
this.todos= [
{
content:'Attend morning call',
completed : false
},
{
content:'Work on task',
completed:false
},
{
content:'Attend classes',
completed : false
},
{
content:'Attend Lab',
completed:false
},
{
content:'Return home',
completed : false
},
{
content:'Continue working on task',
completed:true,
}
]
}
deleteTodo(id: number){
this.todos=this.todos?.filter((v,i) =>i !==id);
}
addTodo(){
this.todos?.push({
content:this.inputTodo,
completed:false
});
this.inputTodo="";
}
}