Angular @LocalStorage
This little Angular/typescript decorator makes it super easy to save and restore automatically a variable state in your directive (class property) using HTML5' LocalStorage.
Seeking new maintainer
This project is not maintained. Please consider taking it over. More information at https://github.com/open-source-chest/take-it-over.
Use
-
Download the library using npm or github:
npm install --save angular-localstorage
-
Import the WebStorageModule in your app module:
;; -
Use the
LocalStorage
decorator
;
Note: Define always a default value at the property you are using @LocalStorage
.
Note: The localstorage key is per default the property name. Define the first argument of @LocalStorage
to set different one.
Note: Please don't store circular structures as this library uses JSON.stringify to encode before using LocalStorage.
Examples