Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
ng-local-storage-service
Advanced tools
[![Bower Version](https://img.shields.io/bower/v/ng-local-storage-service.svg)](https://github.com/justinsa/angular-local-storage-service) [![NPM Version](https://img.shields.io/npm/v/ng-local-storage-service.svg)](https://www.npmjs.com/package/ng-local-
An Angular service for client-side set, get, remove, bind, and clean of local storage mechanisms. It provides fallbacks to cookies or in-memory storage based on client capabilities and service configuration.
##Dependencies
cookieFallback
is enabled.##Features
##Basic Setup
var app = angular.module('yourApp', ['local-storage.service']);
app.controller('yourController', function($scope, $store){ ... });
##Configuration Options
The default configuration is:
To override the default configuration options, configure the module with an options argument during application configuration:
app.config(['$storeProvider', function ($storeProvider) {
$storeProvider.configure({
cookieFallback: false,
useSessionStorage: true
});
}]);
##Basic Usage ###Binding
// Binding it to a $scope.variable - the params ($scope, varName, defaultValue(optional))
$store.bind($scope, 'viewType', 'cardView');
// To change the variable both locally in your controller and in storage
$scope.viewType = "ANYTHING";
###Unbinding
// Unbinding and remove a $scope.variable
$store.unbind($scope, 'viewType');
###Set
// Set a key-value pair in storage
$store.set("key", "value");
###Get
// Get a value from storage
$store.get("key");
###Has
// Determine if a key is present in storage
$store.has("key");
###Remove
// Remove a key-value pair from storage
$store.remove("key");
###Clear
// Clear all key-value pairs from storage
// Note: this is not supported for cookie storage as there is no $cookie service support for such an action.
$store.clear();
##Additional Methods These methods were primarily implemented for testing purposes, but they may be useful in special scenarios and are part of the exposed API.
// Get the configuration hash
$store.getConfiguration();
// Get the value of the supported boolean. This value is used by the service for picking
// the appropriate storage mechanism to use.
$store.getSupported();
// Set the supported boolean. This value is used by the service for picking
// the appropriate storage mechanism to use.
$store.setSupported(false);
// Get the supported storage interface (localStorage or sessionStorage). This variable will be undefined if the Storage interface is not supported.
$store.getStorage();
// Get the in-memory storage object.
$store.getMemStore();
##Development
After forking you should only have to run npm install
from a command line to get your environment setup.
After install you have two gulp commands available to you:
gulp js:lint
gulp js:test
FAQs
[![Bower Version](https://img.shields.io/bower/v/ng-local-storage-service.svg)](https://github.com/justinsa/angular-local-storage-service) [![NPM Version](https://img.shields.io/npm/v/ng-local-storage-service.svg)](https://www.npmjs.com/package/ng-local-
We found that ng-local-storage-service demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.