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:

import { StorageSync , StorageStrategy } from ' angular2-storage-sync ' ; export class AppComponent { @ StorageSync ( ' rememberMe ' ) ; @ StorageSync ( null , StorageStrategy . Session ) ; }

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