Angular2 Storage Sync
Angular2 decorator to sync properties automatically from/to LocalStorage or SessionStorage
Use
npm install --save angular2-storage-sync
- Use in your component:
;
The @StorageSync expects two params:
- Custom key - the default is the property name.
- StorageStrategy - Local or Session - default to LocalStorage.
Important:
Define always a default value at the property you are using @StorageSync
.
Example
@ @ remember: boolean = false; @ items: Array<Object> = ; { // this is always sync with your storage thisitems = id: 1 id: 2; }``