ng2-storage
A service wrapping local and session storage for ng2.
Install
npm i -s ng2-storage
Browser Support
This library makes heavy use of ES6 Proxy, meaning it only has support in the latest Edge, Chrome, Firefox, and Opera.
Usage
First, bootstrap the service globally:
; ;
Next, inject it into a component:
; @ static { return StorageService; } { // you can also use storage.session for sessionStorage thisstorage = storagelocal; } { thisstoragedata = thisstoragedata || 0; thisstoragedata++; }
Options
Name | Default | Description |
---|---|---|
prefix | 'ng2-storage' | The key prefix when assigning data to local or session storage. |
serialize | window.JSON | Used when de/serializing data from the storage container. Both serialize and parse attributes must be specified and must be functions if you want custom ones. |