Last active
December 19, 2021 10:39
-
-
Save Bilkiss/1519ccf62edccc335e4519ccbd4fa565 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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