Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Created June 17, 2019 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavilanch/5701b8a8e5dfb7f95acb08d00361b3ec to your computer and use it in GitHub Desktop.
Save gavilanch/5701b8a8e5dfb7f95acb08d00361b3ec to your computer and use it in GitHub Desktop.
saveTodo() {
// Validate the form
if (this.todoForm.invalid) {
return;
}
let todo: Todo = this.todoForm.value;
todo.lastModifiedDate = new Date();
todo.createdDate = new Date();
this.todoService.saveTodo(todo)
.then(response => this.handleSuccessfulSaveTodo(response, todo))
.catch(err => console.error(err));
}
handleSuccessfulSaveTodo(response: DocumentReference, todo: Todo) {
// Send info to the todo-list component
this.activeModal.dismiss({ todo: todo, id: response.id });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment