This library is a simple wrapper on a localStorage
Run npm install --save ng-simple-storage
import { StorageService } from 'ng-simple-storage
length:
number
- Currently storred items count
items:
{ key: value }
- Currently storred items
onItemChange:
Observable<StorageItemChangeEvent>
- Observable which fires when item in storage changes
clear():
void
- clear storage
getItem<
Type
>(key:
string
):
Type
- return item by key
removeItem<
Type
>(key:
string
):
void
- remove item by key
key(index:
number
):
string
- return the key of item at the specified index
setItem<
Type
>(key:
string
, value:
Type
):
void
- save item with a specified key
setStorage(storage:
Storage
):
void
- change storage used by the service
key:
string
- key of changed item
oldValue:
T
- value of item before event emitted
newValue:
T
- current value of item
You can provide your own implementation of storage by
{ provide: DEFAULT_STORAGE, useValue: CustomStorage }
CustomStorage
must implement Storage
interface