/
githubmirror
/
socket.io
Обзор
Документация
Войти
/
githubmirror
/
socket.io
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/angular-todomvc/src/app/app.component.ts
59 строк
1 KB
Damien Arrachequesne
docs(examples): add Angular TodoMVC + Socket.IO example
17 дек 2020, 14:42
Не верифицирован
17 дек 2020, 14:42
178e899
Код
Авторство
О чём код?
import { Component } from '@angular/core'; import { RemoteTodoStore, Todo } from './store'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { todoStore: RemoteTodoStore; newTodoText = ''; constructor(todoStore: RemoteTodoStore) { this.todoStore = todoStore; } stopEditing(todo: Todo, editedTitle: string) { todo.title = editedTitle; todo.editing = false; } cancelEditingTodo(todo: Todo) { todo.editing = false; } updateEditingTodo(todo: Todo, editedTitle: string) { editedTitle = editedTitle.trim(); todo.editing = false; if (editedTitle.length === 0) { return this.todoStore.remove(todo); } todo.title = editedTitle; } editTodo(todo: Todo) { todo.editing = true; } removeCompleted() { this.todoStore.removeCompleted(); } toggleCompletion(todo: Todo) { this.todoStore.toggleCompletion(todo); } remove(todo: Todo){ this.todoStore.remove(todo); } addTodo() { if (this.newTodoText.trim().length) { this.todoStore.add(this.newTodoText); this.newTodoText = ''; } } }