$localStorage
Provides a key-value (string-object) storage, that is backed by localStorage with support for expiry (in days). Objects put or retrieved from this storage are automatically serialized or deserialized by angular's toJson/fromJson.
$localStorage($window, $location, $cacheFactory);
| Param | Type | Details |
|---|---|---|
| $window | service | The $window service. |
| $location | service | The $location service. |
| $cacheFactory | service | The $cacheFactory service. |
Delete all data from session storage and localStorage.
$localStorage.empty();
Overrides the default domain prefix.
N.B. Destroys the existing cache.
| Param | Type | Details |
|---|---|---|
| val | string | The string to add to the persistent data prefix. |
$localStorage.prefix('myPrefix');
| Param | Type | Details |
|---|---|---|
| key | String | The key of the stored data to remove. |
$localStorage.remove('myKey');
myApp.$inject = ['$localStorage'];
function myApp($localStorage) {
// Your app
}
angular
.module('myApp', ['swxLocalStorage']);