Giter Club home page Giter Club logo

angular-local-storage's People

Contributors

a8m avatar adamquadmon avatar adrianenriquez avatar andion avatar benhoiiand avatar bensinther avatar chicagodave avatar ealves-pt avatar eddiemonge avatar grevory avatar hypercubed avatar idooo avatar kevinsalter avatar kkirsche avatar loftyduck avatar maxrabin avatar michaelnoonan avatar mwickman avatar mwq27 avatar nmehta6 avatar osama-lionheart avatar rijulb avatar robinj avatar rsertelon avatar sbosell avatar simison avatar snede avatar superpaintman avatar yihangho avatar zpgu 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  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

angular-local-storage's Issues

using angular.value instead of angular.constant

Hi,

I am wondering why you chose to use angular.constant. I have a scenario where i have multiple angular apps on the same domain. I would like to reassign the prefix used to store keys individually for each one of the apps. Would you consider using value instead? I can submit a pull request.

Thanks.

Error: 'undefined' is not an object (evaluating '$document.cookie.split')

Get this error when open my site on iPhone:

Error: 'undefined' is not an object (evaluating '$document.cookie.split')

If I try to get $document.cookie.split function locally โ€” get the same error too.

Fix this by removing '$' from '$document':
in line 280 and in line 300:

var cookies = document.cookie.split(';');

Don't know if this is best solution, but it works.

comply with angular naming convention

Use lowerCamelCase and no need of module and service. Whether it's a module or service and be inferred by context.

e.g.

angular.module('yourModule', ['localStorage'])
.controller('yourCtrl', [
  '$scope',
  'localStorage',
  function($scope, localStorage) {
    localStorage.clearAll();
    localStorage.add('Favorite Sport','Ultimate Frisbee');
}]);

Write the release number in the js files

Hi,

Thanks for your project. Very useful.

You made the release 0.0.1, it's good. But you must also report the release number in the js files or how can I know, after download the files, witch release it is ?

bower mismatch

bower extract angular-local-storage#~0.0.4 archive.tar.gz
bower mismatch Version declared in the json (0.0.3) is different than the resolved one (0.0.4)

Use of promise

It would be more fluent if you could add promises to the module.

Example:

localStorageService.get('foo').then(function() {resolve});

Just let me know if i can assist you somehow.

Demo doesnt seem to save any data. Reloads are always blank

I assume the functionality should be that on reload the data remains, but it is always blank when I reload the page.

Using this demo page: http://gregpike.net/demos/angular-local-storage/demo/demo.html

Im on Firefox 27.0.1 on OSX 10.8.4.

Firefox shows 2 warnings on the console:

01:16:29.745 Use of getUserData() or setUserData() is deprecated. Use WeakMap or element.dataset instead. requestNotifier.js:64
01:16:30.462 Use of attributes' specified attribute is deprecated. It always returns true. angular.min.js:39

I assume these are not real issues, so not immediate guesses on why its not working as I havent reviewed the code, only tried the demo.

Missing documentation

I'm trying to save a value in a cookie. I'm not sure what angular-local-storage is meant to do different from angular-cookie.

I've tried to save the cookie with the following code:

localStorageService.clearAll();
localStorageService.set('test_1','test-value');
localStorageService.add('test_2', 'test-value');
localStorageService.cookie.add('test_3', 'test-value');
localStorageService.cookie.set('test_4', 'test-value');

None of the previous command are settings the cookie value. What am I missing?
Why should I use angular-local-storage instead of angular-cookie?

Cheers

Compatibility

Hi thanks your storage works very well, do you have idea of compatibility with the browsers?

automatic cookie fallback

Hi,

I'm not really sure about this, but looks like the module itself doesnt fallback to cookie storage when localStorage not available, does it ?

// If this browser does not support local storage use cookies
if (!browserSupportsLocalStorage()) {
  $rootScope.$broadcast('LocalStorageModule.notification.warning','LOCAL_STORAGE_NOT_SUPPORTED');
  return false;
}

looks like you just send a warning but its never catched ?

i'm a mistaken ? is it a work in progress ? do you need pull request ?

Thanks :)

browserSupportsLocalStorage returns wrong value when DOM Storage is disabled under IE11

browserSupportsLocalStorage always returns true if local storage is not supported when it should return false.

if the var supported is false the function never tries to set an item and returns true as the default. What should happen is that the function should return the value of supported instead of the hard coded value of true.

var browserSupportsLocalStorage = (function () {
  try {
    var supported = (storageType in $window && $window[storageType] !== null);

    // When Safari (OS X or iOS) is in private browsing mode, it appears as though localStorage
    // is available, but trying to call .setItem throws an exception.
    //
    // "QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage
    // that exceeded the quota."
    var key = prefix + '__' + Math.round(Math.random() * 1e7);
    if (supported) {
        webStorage.setItem(key, '');
        webStorage.removeItem(key);
    }

    return supported;
  } catch (e) {
    storageType = 'cookie';
    $rootScope.$broadcast('LocalStorageModule.notification.error', e.message);
    return false;
  }
}());

Remove 'prefix' from inside the cookie methods

It might be cleaner if the cookie methods did not use the prefix internally but instead were passed 'prefix + key' when calling them from the local storage methods. That way the cookie methods exposed can be used for any cookie whilst calls to add to local storage use the prefix as appropriate.

Usage would then be symmetric:

      getFromCookies(prefix + key);
      localStorage.getItem(prefix + key);

isSupported not working

I've been messing around with this module in a small project using node, express and angular and noticed that the isSupported function doesn't work.

In library function browserSupportsLocalStorage, should line

var supported = (storageType in $window && $window[storageType] !== null);

not read

var supported = ("localStorage" in $window) && ($window['localStorage'] !== null)

i.e. referencing item 'localStorage' and not 'storageType'

I see in code that storageType should be defaulting to 'localStorage' so above should work - I'm not sure what's up.

throws exception when localstorage is turned off in chrome

If localstorage and cookies turned off in chrome, it throws exception in 71line:

var webStorage = $window[storageType];

I wrapped this in try-catch block for my project. Maybe you can add too? Or maybe there are more clean solution..

solved: browserSupportsLocalStorage returns wrong value in IE7

Hi, just fixed a bug in the function browserSupportsLocalStorage around line 99. Below is a snippet of code. Sorry, I didn't have time to create a pull-request, but thought someone might find the fix useful too.

        if (supported) {
          webStorage.setItem(key, '');
          webStorage.removeItem(key);
        }

        return supported;

In your code you return True, but it should return the value in the variable "supported" instead, as per above.

Provider for config options

Should the options be set in a provider instead of constants and values so they can be modified in an apps .config() ?

Support synchronous access in IE8

Consider wrapping sessionStorage/localStorage accessors with the following IE8-friendly check:

  if ( webStorage.begin ) {
    webStorage.begin();
  }

  // Local or session storage operation

  if ( webStorage.commit ) {
    webStorage.commit();
  }

Maybe add tests?

Running jshint I get

[L52:C38] W116: Expected '{' and instead saw 'value'.
if (typeof value == "undefined") value = null;
[L78:C16] W116: Expected '{' and instead saw 'return'.
if (!item) return null;
[L123:C46] W033: Missing semicolon.
keys.push(key.substr(prefixLength))
[L176:C38] W116: Expected '{' and instead saw 'return'.
if (typeof value == "undefined") return false;

Warning: Task "jshint:src" failed. Used --force, continuing.

Factory instead of service

I'm not an angularjs guru. Trying to use ALS with angular-translate where in app.config() I can specify my own localstorage service for storing current language infowith:

$translateProvider.useStorage('localStorageService');

I am getting error, that my localstorageservice does not provice set() and get() methods.

Maybe this is related to the "service" nature of angular-storage-service ?
http://stackoverflow.com/questions/15666048/angular-js-service-vs-provide-vs-factory

Thanks

RFE: support for session and local storage simultaneously

It seems that currently the storage type is configured once for the module. But what if an application would like to use both local and session storage? One nice approach may be to have two services exposed from the module: one "localStorageService" and one "sessionStorageService", and either or both may be injected as needed.

update bower

Hi,
the version in bower is outdated (changes from the last commit are missing).
Please update :)

best,
MM.

No longer able to set prefix

Due to change cf39b3c angularLocalStorage is no longer global. How can I now set the prefix constant?

I want to avoid changing localStorageModule.js because I'm installing dependencies from bower.

Please publish to npm

It looks like you have a package.json, but the latest version available on npm is 0.0.1. Can you publish your more recent code?

(Also, it looks like there are some dependencies in package.json that should really be devDependencies.)

Thanks!

Add support for storing objects (enhancement)

Hello, nice library! I was hoping you could add support for storing objects. When I attempt to store an object, it stores as [object Object] and gets the same - rendering the result useless.

I've seen this handled before in https://github.com/jeromegn/Backbone.localStorage by stringifying the object on save and decoding on read. Although, I dont think this library needs to go so far as to replicate a noSQL database (as the backbone library does).

As an idea on how to implement, we could modify the add(key, value) method to check if typeof value === "object" and thes stringify the value. I assume something similar when reading values.

Thoughts?
-Matt

License?

What's the license for this project?

tag repo

if 0.0.1 version is done, please tag it in github so we can force version in bower install :)

Synced value between multiple tabs

Hi there, does this library support watching a given key in the localStorage? This way I could keep my app state synced in multiple tabs.

Thanks.

using localstorage in config()

For you know, settings default params and stuff. Since services can't be injected into config block, it'd have to be a provider or something..

Undefined function 'get' in parent controller

I have an abstract parent controller with a child state using ui-router. When I refresh the page I get an undefined error for localStorageService.get. It looks like I have the provider instead of the service immediately after a refresh ( which is when I would want the service to work )

Values 'set' as number are changed to string after 'get'

When I made a round trip (set and then get) my numeric values came back as strings.

localStorageService.set("page_number", n); // n === 1
n = localStorageService.get("page_number"); // n === "1"

np, I fixed it with:

n = parseInt(localStorageService.get("page_number"), 10);

but I thinkit would be better to preserve the basic JSON types.

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.