Reputation: 19
I am new in Angular 4. Please explain How to implement session functionality in angular 4. Step by step process and where to write code for that. i am trying to implement below code but need direction to implement
saveInLocal(key, val): void {
console.log('recieved= key:' + key + 'value:' + val);
this.storage.set(key, val);
this.data[key]= this.storage.get(key);
}
Upvotes: 1
Views: 216
Reputation: 847
Wherever you want to set session info you can just do
window.sessionStorage.setItem('myKey', myValue);
to get it:
const sessionValue = window.sessionStorage.getItem('myKey');
Upvotes: 1