Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created September 7, 2021 01:28
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/a5e5704f05928778d43d26ad5c58f5e6 to your computer and use it in GitHub Desktop.
Save parzibyte/a5e5704f05928778d43d26ad5c58f5e6 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { TareaPendiente } from './tarea-pendiente';
@Injectable({
providedIn: 'root'
})
export class TareasService {
CLAVE_LOCAL_STORAGE = "tareas_angular"
constructor() { }
obtenerTareas(): TareaPendiente[] {
return JSON.parse(localStorage.getItem(this.CLAVE_LOCAL_STORAGE) || "[]")
}
guardarTareas(tareas: TareaPendiente[]) {
localStorage.setItem(this.CLAVE_LOCAL_STORAGE, JSON.stringify(tareas))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment