Created
May 25, 2019 13:45
-
-
Save itayod/e622619568e9113a11e4b389c19f6250 to your computer and use it in GitHub Desktop.
This file contains 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 LocalStorageService { | |
constructor() {} | |
setSavedState(state: any, localStorageKey: string) { | |
localStorage.setItem(localStorageKey, JSON.stringify(state)); | |
} | |
getSavedState(localStorageKey: string): any { | |
return JSON.parse(localStorage.getItem(localStorageKey)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment