Giter Club home page Giter Club logo

ngstorage's Introduction

ngStorage

Build Status Dependency Status devDependency Status

An AngularJS module that makes Web Storage working in the Angular Way. Contains two services: $localStorage and $sessionStorage.

Differences with Other Implementations

  • No Getter 'n' Setter Bullshit - Right from AngularJS homepage: "Unlike other frameworks, there is no need to [...] wrap the model in accessors methods. Just plain old JavaScript here." Now you can enjoy the same benefit while achieving data persistence with Web Storage.

  • sessionStorage - We got this often-overlooked buddy covered.

  • Cleanly-Authored Code - Written in the Angular Way, well-structured with testability in mind.

  • No Cookie Fallback - With Web Storage being readily available in all the browsers AngularJS officially supports, such fallback is largely redundant.

Install

Bower

bower install ngstorage

NOTE: We are ngstorage and NOT ngStorage. The casing is important!

NPM

npm install ngstorage

NOTE: We are ngstorage and NOT ngStorage. The casing is important!

nuget

Install-Package gsklee.ngStorage

Or search for Angular ngStorage in the nuget package manager. https://www.nuget.org/packages/gsklee.ngStorage

CDN

cdnjs

cdnjs now hosts ngStorage at https://cdnjs.com/libraries/ngStorage

To use it

<script src="https://cdnjs.cloudflare.com/ajax/libs/ngStorage/0.3.10/ngStorage.min.js"></script>

jsDelivr

jsDelivr hosts ngStorage at http://www.jsdelivr.com/#!ngstorage

To use is

<script src="https://cdn.jsdelivr.net/npm/[email protected]/ngStorage.min.js"></script>

Usage

Require ngStorage and Inject the Services

angular.module('app', [
    'ngStorage'
]).controller('Ctrl', function(
    $scope,
    $localStorage,
    $sessionStorage
){});

Read and Write | Demo

Pass $localStorage (or $sessionStorage) by reference to a hook under $scope in plain ol' JavaScript:

$scope.$storage = $localStorage;

And use it like you-already-know:

<body ng-controller="Ctrl">
    <button ng-click="$storage.counter = $storage.counter + 1">{{$storage.counter}}</button>
</body>

Optionally, specify default values using the $default() method:

$scope.$storage = $localStorage.$default({
    counter: 42
});

With this setup, changes will be automatically sync'd between $scope.$storage, $localStorage, and localStorage - even across different browser tabs!

Read and Write Alternative (Not Recommended) | Demo

If you're not fond of the presence of $scope.$storage, you can always use watchers:

$scope.counter = $localStorage.counter || 42;

$scope.$watch('counter', function() {
    $localStorage.counter = $scope.counter;
});

$scope.$watch(function() {
    return angular.toJson($localStorage);
}, function() {
    $scope.counter = $localStorage.counter;
});

This, however, is not the way ngStorage is designed to be used with. As can be easily seen by comparing the demos, this approach is way more verbose, and may have potential performance implications as the values being watched quickly grow.

Delete | Demo

Plain ol' JavaScript again, what else could you better expect?

// Both will do
delete $scope.$storage.counter;
delete $localStorage.counter;

This will delete the corresponding entry inside the Web Storage.

Delete Everything | Demo

If you wish to clear the Storage in one go, use the $reset() method:

$localStorage.$reset();

Optionally, pass in an object you'd like the Storage to reset to:

$localStorage.$reset({
    counter: 42
});

Permitted Values | Demo

You can store anything except those not supported by JSON:

  • Infinity, NaN - Will be replaced with null.
  • undefined, Function - Will be removed.

Usage from config phase

To read and set values during the Angular config phase use the .get/.set functions provided by the provider.

var app = angular.module('app', ['ngStorage'])
.config(['$localStorageProvider',
    function ($localStorageProvider) {
        $localStorageProvider.get('MyKey');

        $localStorageProvider.set('MyKey', { k: 'value' });
    }]);

Prefix

To change the prefix used by ngStorage use the provider function setKeyPrefix during the config phase.

var app = angular.module('app', ['ngStorage'])
.config(['$localStorageProvider',
    function ($localStorageProvider) {
        $localStorageProvider.setKeyPrefix('NewPrefix');
    }])

Custom serialization

To change how ngStorage serializes and deserializes values (uses JSON by default) you can use your own functions.

angular.module('app', ['ngStorage'])
.config(['$localStorageProvider', 
  function ($localStorageProvider) {
    var mySerializer = function (value) {
      // Do what you want with the value.
      return value;
    };
    
    var myDeserializer = function (value) {
      return value;
    };

    $localStorageProvider.setSerializer(mySerializer);
    $localStorageProvider.setDeserializer(myDeserializer);
  }];)

Minification

Just run $ npm install to install dependencies. Then run $ grunt for minification.

Hints

Watch the watch

ngStorage internally uses an Angular watch to monitor changes to the $storage/$localStorage objects. That means that a digest cycle is required to persist your new values into the browser local storage. Normally this is not a problem, but, for example, if you launch a new window after saving a value...

$scope.$storage.school = theSchool;
$log.debug("launching " + url);
var myWindow = $window.open("", "_self");
myWindow.document.write(response.data);

the new values will not reliably be saved into the browser local storage. Allow a digest cycle to occur by using a zero-value $timeout as:

$scope.$storage.school = theSchool;
$log.debug("launching and saving the new value" + url);
$timeout(function(){
   var myWindow = $window.open("", "_self");
   myWindow.document.write(response.data);
});

or better using $scope.$evalAsync as:

$scope.$storage.school = theSchool;
$log.debug("launching and saving the new value" + url);
$scope.$evalAsync(function(){
   var myWindow = $window.open("", "_self");
   myWindow.document.write(response.data);
});

And your new values will be persisted correctly.

Todos

  • ngdoc Documentation
  • Namespace Support
  • Unit Tests
  • Grunt Tasks

Any contribution will be appreciated.

ngstorage's People

Contributors

alexgorbatchev avatar cayblood avatar chbrown avatar dcendents avatar dotansimha avatar dpogue avatar dvelasquez avatar egilkh avatar everdimension avatar graywolf336 avatar jak-pan avatar jcompagner avatar jlkalberer avatar kbaltrinic avatar krtek avatar lperrin avatar luisegr avatar lukasdrgon avatar manumiranda avatar nano1237 avatar overzealous avatar passy avatar patrickjs avatar roaks3 avatar robinboehm avatar rortegax2 avatar stylenclass avatar williamboman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngstorage's Issues

Access is denied in IE9/11 - webStorage line 79 ngStorage.js

Getting an error in IE9 and 11 with Access is denied. Its not on all machines, and so first thought was security settings.

IE debugged and said that line 79 in ngStorage.js webStorage.removeItem('ngStorage' + k); it expected a function.

What does it mean?

Add lz-string Compression

The lz-string is a compression library built for localStorage. It is super fast, geared towards the small values that are typically stored in localStorage, and only ~1.5KB when compressed.

How to wait on delete to take place

In my app, when a user logs out I want to

  1. Delete their auth token from $localStorage.
  2. Reload the page

I noticed that this code wasn't working:

delete $localStorage.authToken;
$window.location.href = '/';

When the page reloads, the auth token is still present.

So, as an experiment I put the reload in a timeout and it worked.

delete $localStorage.authToken;
$timeout(function () {
    $window.location.href = '/';
}, 110);

I also noticed that the timeout had to be greater than 100... which leads me to believe that this has something to do with _debounce section in your code, which I don't quite understand, yet.

What's the best way that I can be sure that the data has been removed from web storage before reloading the page?

Looking for Maintainers

Hi everyone, sorry for the dead silence for quite a long time.

To put it short, I've moved away from the Angular ecosphere and am not very likely to invest any more substantial amount of time into this project, so I've decided to open it up for those who actively use it in their daily developments.

I've got no prior experience on this so I'm not sure if turning this repo into an organization is good or bad, so please weigh in and share your thoughts on the pros and cons of establishing an organization to oversee this project.

Also if you're interested in helping to maintain and shape the future of ngStorage, you're more than welcome to give a shout below and let us know how you'd like to help.

cc @egilkh @raynode @sompylasar @AyogoHealth @scalablepress @halkon and thanks for your past contributions!

.bower.json causing errors

the last couple lines of the .bower.json file seem to be malformed. It's blowing up my bower tasks...

{
  "name": "ngstorage",
  "main": "./ngStorage.js",
  "keywords": [
    "angular",
    "cookie",
    "storage",
    "local",
    "localstorage",
    "session",
    "sessionstorage"
  ],
  "dependencies": {
    "angular": ">=1.0.8"
  },
  "devDependencies": {
    "angular-mocks": ">=1.0.8",
    "chai": "~1.8.1"
  },
  "homepage": "https://github.com/gsklee/ngStorage",
  "version": "0.3.0",
  "_release": "0.3.0",
  "_resolution": {
    "type": "version",
    "tag": "0.3.0",
    "commit": "b68fef8a722a7d15c00d4d41041b96f95e867208"
  },
  "_source": "git://github.com/gsklee/ngStorage.git",
  "_target": "0.3.0"
}target": "*"
}

support for configuration storage key prefix

for now every value in storage has prefix 'ngStorage-'
would be nice if this can be configured via service provider
i think i even can send pull request if you wish but some later this week

Support IE8 with attachEvent

I haven't tested but the event listener isn't likely to work because window.addEventListener() is not available on IE8.

IE8 is the lowest version of IE supported by Angular, so I think ngStorage should support it as well.

Fix is to check if window.addEventListener exists, and if not, fall back to window.attachEvent.

Will try to send PR later today.

Problematic default localStorage content in Chrome

In my Chrome installation, localStorage is by default filled with {'preview_position': undefined}. This causes an error on loading this module, because angular.fromJson() won't parse the undefined value.

I am using a very naive workaround in _storageFactory():

for (var i = 0, k; k = webStorage.key(i); i++) {
     if (k != 'preview_position'){
          $storage[k] = angular.fromJson(webStorage.getItem(k));
     }
}

Is it possible/desirable to handle undefined values elegantly in general?

if you have a empty key in local or session storage the load breaks completely

this is because the code has this if:

for (var i = 0, k; i < webStorage.length && (k = webStorage.key(i)); i++) {
'ngStorage-' === k.slice(0, 10) && ($storage[k.slice(10)] = angular.fromJson(webStorage.getItem(k)));
}

i changed it to:

for (var i = 0, k; i < webStorage.length; i++) {
if ((k = webStorage.key(i))) {
'ngStorage-' === k.slice(0, 10) && ($storage[k.slice(10)] = angular.fromJson(webStorage.getItem(k)));
}
}

and then it works, because it shouldn't completely skip the whole loop if somehow "k" evalutes to false (because the key is an empty string)

somehow i get such a key in my local and session storage, can't currently find out why that is (""=null) i don't use the local and session storage at all my self so it must be a 3th party lib, that maybe tries to test if the storage are available and doesn't remove that key
But nsStorage shouldn't just not work if a key is not what it expects it to be (if that is not a key of nsStorage itself)

binding for particular key in storage

currently this binds the full storage, and probably won't work well with existing projects that already use storage - since each sync is essentially a clear-and-set, not atomic.

allowing binding particular key to a scope variable might be useful, similar to the angularFire api.

grunt minify task on ngStorage.js does not work

I run $grunt on my vendors scripts, ngStorage.js is one of them.
after grunt is done, the vendor.js file is created with error. Once I removed ngStorage, the error disappeared from the vendor.js file

Changing the name of the key - localStorage

I'm trying to edit the key name on localStorage.
On the source code, I can see that the name is "ngStorage-", but I would like to add a variable to the keyname.

For example: ngStorageVAR-.

I tried change it but when I change the nameKey to something else I never get back the information stored on local, only when using the default it works

'binding' $scope variables for persistence

Can it be simpler to store $scope variables?

From within a controller, I can assign the stored variable to a $scope variable like below:
if (!$scope.$storage.detailsQueue) { $scope.$storage.detailsQueue = []; }
$scope.detailsQueue = $scope.$storage.detailsQueue;
I could also use $default for initialization.
$default( { detailsQueue : [] } )

Is there already a simple, single statement, syntax I missed?

If not, maybe something like :
$storage.bind($scope,'varName',{defaultValue: 'randomValue123' ,storeName: 'customStoreKey'}); as found in https://github.com/agrublev/angularLocalStorage

The use case being to avoid editing existing code by declaratively providing immediate storage to existing variables.

Regards,

Use anonymous AMD definition

Change the AMD definition to anonymous instead of the named one.

Named definitions severely limit the flexibility of AMD approach when used in larger projects. In fact, in some situations, having a named definition can be much worse than not having any. For more details, refer to the this comment I've made on a similar issue in Moment.js library: moment/moment#1095 (comment)

On a bright side, this is trivial to fix, and shouldn't break anything for those that are already using it in current form.

Custom parsers

Some variables need to be re-instantiated on load.

We should be able to specify parser function(s) to do this.

Also, $sessionStorage should be instantiated so it can contain options and values specific to the target scope's usage.

Example solution --

$scope.$storage = $sessionStorage({
    parseFromStorage: {
        myobject: function(value) {
            return new FunkyObject(value);
        }
    },
    defaults: {
        myobject: new FunkyObject();
    }
});

Unable to make it works

Hi ! I discovered only today this module. Thanks a lot.

I've this problem.

I've my app defined as

var app = angular.module('myApp', ['fsCordova', 'ngRoute', 'mobile-angular-ui', 'ngStorage']);

Then i created controller as

app.controller('SearchController', [ '$scope', '$http', function($scope, $http, $localStorage) {

   $scope.product = {
        code : "",
        data : null,
        status : null,
        headers : null,
        config : null,
   }

   $scope.$storage = $localStorage.$default({
        last_search : "none",
    })

But at the line 'app.controler...' i get

Error: $localStorage is undefined.

What am I missing?

I've not used bower to install. I simply downloaded the file ngStorage.min.js

Access from a provider or config block not possible with current implementation choices.

Hi,

Could it be possible to register $sessionStorage and $localStorage using providers instead of factory to allow usage of storage in application providers / configuration blocks.

I know that the usage of $rootScope you do in your implementation will cause problem in this approach, but maybe you could just implement good old plain get() and set() methods to access the local/session storage from providers without providing the angular binding magic ?

My use case is simple (and I think, one of the most commun use case for local/session storage ) : a configuration block who must read in the sessionStorage to inject a custom security header using $httpProvider.

NPM compile-time dependencies included in production section

The current version of ng-storage on npm is unusable, because it pulls down grunt, karma, etc in its production dependencies. Because there is some kind of peer dependency issue, this causes all subsequent npm install operations to fail. Grunt, Karma, etc. should only be included in the development scope and be completely unnecessary during production use.

Perhaps use throttled $watch instead of addPollFn?

I see why you used addPollFn instead of $rootScope.$watch; for many rapid actions you don't want to do a potentially huge compare every $digest.

But if I use this, I also don't want to have a potentially huge compare every 100ms, especially on things like android 2.x browser.

...so what if on every $digest, if there's no timeout, you set a new timeout to compare in 100ms?

ngStorage crashes the whole application when ran in an iframe

Chrome prevents access to cookies and local storage if the page is load in an cross domain iframe and cookie settings are set to block third party cookies.

Error: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
    at Error (native)
    at Object. (https://rawgit.com/gsklee/ngStorage/master/ngStorage.js:42:41)
    at Object.d [as invoke] (https://code.angularjs.org/1.1.5/angular.min.js:28:304)
    at https://code.angularjs.org/1.1.5/angular.min.js:30:39
    at c (https://code.angularjs.org/1.1.5/angular.min.js:27:142)
    at d (https://code.angularjs.org/1.1.5/angular.min.js:27:276)
    at Object.instantiate (https://code.angularjs.org/1.1.5/angular.min.js:28:434)
    at https://code.angularjs.org/1.1.5/angular.min.js:53:326
    at https://code.angularjs.org/1.1.5/angular.min.js:44:274
    at n (https://code.angularjs.org/1.1.5/angular.min.js:7:74) 

To demonstrate the issue I took the demo from your readme.md and put it into a jsfiddle iframe.

As you can see the application crashes and can't even bootstrap in Chrome

$scope.$storage = $localstorage puts everything inside current scope in storage

Weird bug?

This is the code I'm using:

$scope.organisation = {
    id: 0
};

$scope.updateOrganisation = function (organisation) {
    console.log(organisation);
}

$scope.load = function (adUsername) {

    $scope.$storage = $localStorage;
    // function logic
}

And for some weird reason it's placing everything within my $scope inside my local storage. Any info on this?

Breaks on reload page or exiting and coming back.

I create the keys and on first load it is all fine. Exit and come back to the app or just hit refresh and I get:

SyntaxError: Unexpected token J
at Object.parse (native)
at Object.pb as fromJson
at Object. (http://up.dev/pt/js/ngStorage.js:63:85)
at Object.d as invoke
at http://up.dev/pt/js/angular.min.js:29:339
at c (http://up.dev/pt/js/angular.min.js:27:13)
at d (http://up.dev/pt/js/angular.min.js:27:147)
at Object.instantiate (http://up.dev/pt/js/angular.min.js:28:304)
at http://up.dev/pt/js/angular.min.js:52:239
at http://up.dev/pt/js/angular.min.js:43:348 angular.min.js:62

I have the following stored:
ngStorage-locationid: 1
ngStorage-trainerfirst: James
ngStorage-trainerid: 3
ngStorage-trainerlast: Taylor

If I delete local storage the issue goes away

Keep $localStorage in sync between tabs

I have a problem with two concurrently open tabs:

  1. I change something in tab 1, say $localStorage.myList
  2. If I'm $watching the same object ($scope.list = $localStorage.myList) in tab 2, the listener is triggered, but $localStorage.myList still contains the old value!

I have noticed that the angular.element($window).bind('storage', function(event) {}) part is called in the second tab, but it never updates $storage!

Can this be fixed? I think it can by simply recreating the $storage starting from the localStorage javascript object.

localStorage will not updated (after reload the current value is not there)

I have an application where I use ngStorage to save some time values which will decreased every second, but with ngStorage the current time value will not shown after reload (its only decreased by one).
To demonstrate this I have created an plunker:
http://plnkr.co/edit/d48NAdAoS03qzAi3N9ND?p=preview
Just input a integer and submit. After a while reload the page.
The ngStorage value is than just decreased by one, but the localStorage value has the correct time. Why is that?

Now some explanation why my code is a little more complex to demonstrate this behaviour:
In my real app the timevalue is a json object with a few timevalues in it and in the timewaitingService the setWait function calcs the lowest one to show this to the audience. Also in the tick function every timevalue will be decreased by one every second. So I like to show this demonstration code as near as possible to my code in the real app. May its my fault, because it is my first app using angular js. May somebody can explain why the timevalue will not be updated every second, but if I use the plain localstorage function it will.

Setting localStorage does not reflect in $localStorage

It appears that setting localStorage in plain javascript is not picked up by ngStorage.

That is, when doing either

localStorage.setItem('key', 'value') OR
localStorage['key'] = 'value'

changes are not propagated to the DOM.

Why would I want to do this? I'd like to persist part of localStorage across user logins by backing it up to the server and pushing it down to the client when necessary.

I think I could potentially wrap this in angular, but I'd prefer to not do that.

The solution may be easy too. Reading the code, it looks like there is an internal copy of the webStorage object that is saved in JS memory to compare it with at $watch intervals. Why not simply check against the webStorage object?

Handle non-JSON values gracefully

ngStorage currently demands control over the complete localStroage. This is problematic if you use other plugins that store data in it, especially if this data is not valid JSON.

Adding a try/catch block around JSON.parse already help a lot, but I'm not sure if this in line with your design decisions. Should it just silently ignore invalid values, print a warning or anything like that?

Issues on Windows Phone (Mobile IE 9&10)

For some reason, this module fails on Windows Phone -platforms. The module does not persist data to web storage properly. The origin of the issue is on line 77:

delete _last$storage[k];

For some reason, this does not properly delete the keys from the _last$storage-object. Only the last delete operation of the forEach-loop persists and this causes the next for loop (for (var k in _last$storage) {...}) to remove everything except the last item from web storage.

Dates get squashed into strings, consider customer serializer support?

Adding a date to either $localStorage or $sessionStorage results in the date eventually becoming a string at some point (i.e. when the app reloads). This is of course because when the date is added, it gets serialized to a string, but remains a date in $localStorage/$sessionStorage until something happens (browser reload) to cause the object to be reloaded from storage, then suddenly what was a date is now a string.

This is arguably something of a "known issue" since this is the behavior of the underlying toJson/fromJson methods. However since ngStorage goes to the trouble of hiding the true string nature of the storage from the developer (thank you), the behavior is in effect a leaky abstraction. Moreover, accounting for this behavior in code is messy.

Arguably other things also do not serialize and deserialize symmetrically either. (regular expression or most any other object that is not just a hash map). Therefore implementing a hard coded fix for dates may be a slippery slope, not to mention breaking backward compatibility.

However, it would be possible to introduce the ability to inject customer serialization/deserialization functions into the services at configuration time. What are your thoughts on such a feature?

bower install ngStorage installs old version

When I try to install ngStorage with the command 'bower install ngStorage --save' it downloads an older version of ngStorage than the one in this repository. Maybe this is a problem with Bower, but I just wanted to mention it

Bug when storing complex objects on mobile devices (cordova, iOS)

This bug has cost me days of investigation. When storing complex objects, the objects can be accessed while app is running but on reload they are lost. I switched to angular-locker, changed nothing else in my code than getters/setters and it works like a charm ...

Module won't load

In version 0.3.0 the injection with ngStorage has no problems. When updating to 0.3.3, appears error of injection.
May be due the define in ngStorage.js using "ngStore" instead of "ngStorage":

(function(angular, factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        define('ngStore', ['angular'], function(angular) {
            return factory(angular);
        });
    } else {
        return factory(angular);
    }
}

NgStorage connected to input or textarea

Hi, I have been trying to use ngStorage and connect $storage.text for example to a input or a textarea by using the ngModel attribut. It kind of works but when the user types fast in the field the text flip back and character gets erased all the time. Do you have any example for how this should be done to avoid these effects?

/best regards, Magnus

npm install ng-storage is huge!

npm install ng-storage installs all devdependencies, which is 50MB of files

please can you consider moving all the grunt and karma stuff and so on into devdepencies?

Syncing state of complex models with local/session storage

In my app I've created services to initialize and maintain complex models. However, updates to the model aren't being reflected in local/session storage and I'm not sure how to proceed? The following is highly contrived, but hopefully gets the point across...

angular
    .module('Survey',['ngStorage'])
    .factory('Answer',($sessionStorage,$stateParams) ->
        _blankAnswer = {
            title: null
            value: null
        }
        class Answer
            constructor: ->
                survey_id = $stateParams.survey_id
                question_id = $stateParams.question_id
                angular.extend(this, $sessionStorage.surveys[survey_id].questions[question_id].answer || _blankAnswer)
            # methods & custom attrs here
    )
    .controller('answerCtrl',(Answer) ->
        $scope.answer = new Answer()
    )

A change to this model is not reflected in the $sessionStorage object...

    <label>{{answer.title}}</label>
    <input type="text" ng-model="answer.value">

Is there a better way to approach this? Do I need to pass the $scope into my service and place a $watch on all of the attributes I might be changing? That scares me a little...

Custom property in an array

If something is being stored inside some custom property of an array, that data will not make it's way into JSON and subsequently web storage. Not sure if there is anyway to solve this actually.

$reset does not remove items from webStorage

I just recently tried this ngmodule and found that when I reset the storage when I try to access the $sessionStorage it reloads the data, because it is still there... I patched it locally to make it work in this way:

$reset: function(items) { for (var k in $storage) { '$' === k[0] || (delete $storage[k] && webStorage.removeItem('ngStorage-' + k)); }
                        return $storage.$default(items);
                    }

Hope this helps.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.