mirror of
https://github.com/LucasVbr/todo-list.git
synced 2026-07-09 15:17:49 +00:00
Edit localStorage changes
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="columns" *ngFor="let item of list">
|
<div class="columns" *ngFor="let item of list">
|
||||||
<input type="checkbox" [(ngModel)]="item.checked" name="{{ item.text }}" id="{{ item.text }}">
|
<input type="checkbox" [(ngModel)]="item.checked" (ngModelChange)="saveList()" name="{{ item.text }}" id="{{ item.text }}">
|
||||||
<label class="checkbox pl-2" for="{{ item.text }}">
|
<label class="checkbox pl-2" for="{{ item.text }}">
|
||||||
{{ item.text }}
|
{{ item.text }}
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class AppComponent implements OnInit {
|
|||||||
if (this.inputValue && !listOfTodoText.includes(this.inputValue)) {
|
if (this.inputValue && !listOfTodoText.includes(this.inputValue)) {
|
||||||
this.list.push(new TodoItem(this.inputValue))
|
this.list.push(new TodoItem(this.inputValue))
|
||||||
this.inputValue = "";
|
this.inputValue = "";
|
||||||
this.saveList();
|
this.saveList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ export class AppComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
removeItem(toRemove: TodoItem): void {
|
removeItem(toRemove: TodoItem): void {
|
||||||
this.list = this.list.filter(item => item !== toRemove);
|
this.list = this.list.filter(item => item !== toRemove);
|
||||||
this.saveList();
|
this.saveList()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,11 +46,11 @@ export class AppComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
removeCheckedItems(): void {
|
removeCheckedItems(): void {
|
||||||
this.list = this.list.filter(item => !item.checked)
|
this.list = this.list.filter(item => !item.checked)
|
||||||
this.saveList();
|
this.saveList()
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveList(): void {
|
saveList(): void {
|
||||||
LocalService.saveData(this.LOCAL_STORAGE_KEY, this.list);
|
LocalService.saveData(this.LOCAL_STORAGE_KEY, this.list);
|
||||||
|
console.log(this.list)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user