Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 7, 2021 01:40
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 parzibyte/249c30836150e7f89eeb86a096553790 to your computer and use it in GitHub Desktop.
Save parzibyte/249c30836150e7f89eeb86a096553790 to your computer and use it in GitHub Desktop.
/*
Nota: aquí utilizo el índice porque solo trabajo con un array. Si tú usas
una base de datos probablemente quieras usar el ID del elemento en lugar del índice
*/
eliminarTarea(indice: number) {
// Primero le preguntamos al usuario
const confirma = confirm("¿Realmente quiere eliminar la tarea?");
if (!confirma) {
return;
}
// Eliminamos del arreglo y guardamos
this.tareas.splice(indice, 1);
this.tareasService.guardarTareas(this.tareas);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment