ngScopeStorage
An AngularJS module that binds $scope to the browser storage
Installation
- NPM:
$ npm install ngscopestorage
- CDN:
- Download/Clone this repo and include
ngscopestorage.min.js
in your project
What's ngScopeStorage?
ngScopeStorage produce a 3 way data-binding by extending $scope's bindings ability.
In other words this module allow $scope to bind his properties to local/session storage.
View <-- $scope --> BrowserStorage (local/session storage)
Quick start
angular ;
Now you can Use it:
- In your View with {{ }}:
{{variableToBind}}
- And read it from BrowserStorage with $vms.prefix:
localStorage);
Setting up
- Install ngScopeStorage
- Include it in your app
angular.module('app', ['ngScopeStorage'])
- Inject
$vms
provider to your controllercontroller('ctrl', ['$scope','$vms', function($scope,$vms){})
- Use
$vms.config
to feed the module with some necessary configurations NOTE: you must call this function in order the module to work properly.$vms.config
function takes an JSON object with the following properties as an argument:- scope - The $scope of the controller from which you use the module (Object) required
- ctrlName - The name of the controller from which you use the module (String) (Default:"http://localhost") required
- prefix - A Unique name that will be saved alongside with your variables in the storage (String) (Default:"vms") optional
- storageType - The storage in which your variables will be saved (localStorage/sessionStorage) (String) (Default:"localStorage") optional
- onReload - A Setting determines whether the model will clear the data from storage on page reload or keep it (empty/save) (String) (Default:"empty") optional
- Attach any properties that you want to
$vms
- Enjoy :)