Skip to content

Instantly share code, notes, and snippets.

@Bilkiss
Last active December 19, 2021 10:39
Show Gist options
  • Save Bilkiss/1519ccf62edccc335e4519ccbd4fa565 to your computer and use it in GitHub Desktop.
Save Bilkiss/1519ccf62edccc335e4519ccbd4fa565 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class StorageService {
constructor() { }
set(key: string, value: any): void {
let val = JSON.stringify(value);
localStorage.setItem(key, val);
}
get(key: string): any {
return JSON.parse(localStorage.getItem(key)) ;
}
remove(key: string): void {
localStorage.removeItem(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment