Angular Local Storage 💾

Angular + Local Storage

Recently I was implementing local storage in Angular. I came across the marcj angular2-localstorage. He is using decorator which makes it super easy to save and restore automatically a variable state in local or session storage.

Usage

In your component just decorate your variable with @LocalStorage or @SessionStorage and you are done.

Local Storage

It’s great idea but he’s implementation is quite swollen. So I have decided to implement it on my own. Here is minimal example to understand how it works. So you can implement it on your own.

Session Storage

For session storage it’s alike.

Related Post

MacBook wifi issue – OS X keeps reconnecting Last few weeks I was facing annoying wifi problems. My mac was reconnecting every 5 minutes. On top of that BSSID was reseting so I saw BSSID changing...
Right Click to Create New File on Mac OS X TL;DR; Windows has a lot of cons but it has also some pros. One of them is a smooth way to create empty file on right-click. Mac OS doesn't come with...
Convert HEIC to JPG on Right Click for Free Convert HEIC to JPG on Right-Click In iOS 11 Apple is replacing the JPEG image format with the new HEIC alternative. But what to do when device or p...
FREE ePub Quicklook and Spotlight Plugins for Mac ... When you have a lot of ePub books, it can be useful to see excerpt and meta data information in quicklook. Even more important...
Free Better Battery Stats and Time Remaining for M... Better Battery Stats and Time Remaining for Mac OS TL;DR; Do you miss the time remaining indicator on your MacBook, MacBook Air, or MacBook Pro? He...
Translate Selected Text to English on Right Click ... TL;DR; Need instant translation right in context menu? You can accomplish it for free with one line of code in Automator, or you can proc...
Buy me a coffeeOut of coffee 😱, please help!