Giter Site home page Giter Site logo

angularlocalstorage's People

Contributors

agrublev avatar camaross avatar elexy avatar hppycoder avatar jarcoal avatar matohawk avatar panuhorsmalahti avatar peterdavehello avatar robwalch avatar voronianski 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

angularlocalstorage's Issues

Prevent ngRepeat duplicate error

if localstorage bound object is used in ngRepeat, then the object will be persisted to localstorage with $$hashkey, potentially causing the aforementioned error. this can either be addressed by using track by in the ngRepeat construct or adjusting the code in angularlocalstorage to strip the hashkey before set.

recommended change:
var saver = $window.JSON.stringify(value, function(key, val) {
if(key == '$$hashKey') {
return undefined;
}
return val;
});

use new version of angular?

angular is now 1.2.rc2, as well as angular-cookies, can you upgrade to the new version and push a new build to bower?

Add to Bower

It will be very useful to have it as bower package!

Ng-repeat error because of dupes.

Fix: change "var saver = $window.json.." to:
var saver = $window.JSON.stringify(value, function (key, val) {
if (key == '$$hashKey') {
return undefined;
}
return val;
});

bower ngStorage

Hi!

I was curious if you might consider unregistering the bower package called "ngStorage"?

It currently installs this package. But your readme indicates you have a new name for this package with a new bower name as well?

add .clear() functionnality

Hi

First, I'm using your lib for a while now and it's very helpfull ;)
There is still one thing I think is missing : the possibility to clear the localStorage in one shot. It's doable with .clear() function in W3C localStorage.

Do you think it's possible to add this to your lib ?

Thanks ;)

bower folder name

I think new version of bower has renamed components to bower_components, thus your example code is broken on my box (unless I forked your src repo).

I personally think it makes more sense of NOT checking in "components" folder as src so you won't run into dependencies management hell.

The components folder should be removed

I think this folder should be removed. The examples could reference a public angularjs cdn, or the dependencies could be fetch using bower for the example.

Reason for removing: it wastes space and increases maintenance.

bind and $$hashKey

app.controller('CreateCtrl', function ($scope) {
      $scope.create = {a:1, b:2, c:3};
      $scope.send = function () {
         $scope.$emit('send', angular.copy($scope.create));
      }
});
app.controller('ListCtrl', function ($scope, $rootScope) {
      $scope.list = [];
      $rootScope.$on('send', function (e, data) {
         $scope.list.push(data);
      });
}) ;

last element in $scope.list on LocalStorage does not have a $$hashKey if $scope.list bind to Storage. because of this error happens ng repeat dupes (duplicate)

"bower install angular-localStorage" broken ?

Cannot use bower: bower install angular-localStorage

causes error:

bower not-cached git://github.com/grevory/angular-local-storage.git#~0.1.1
bower resolve git://github.com/grevory/angular-local-storage.git#~0.1.1
bower ENORESTARGET No tag found that was able to satisfy ~0.1.1

Additional error details:
No versions found in git://github.com/grevory/angular-local-storage.git

GitHub Release 0.3.0

Please release officially 0.3.0, to denote the change in the bower.json file.

get method using jquery cookie

the get method implementation in (!support) if branch is using jquery cookie when perhaps it should be using angular cookieStore.

recommend change
return privateMethods.parseValue($.cookie(key));
to
return privateMethods.parseValue($cookieStore.get(key));

Private Browsing in Safari Breaks

When I try to use localStorage on Safari while private browsing I get an error that I cannot catch.

Cookie 'config' possibly not set or overflowed because it was too large (1018591 > 4096 bytes)!

Looks like the fallback to the $cookieStore isn't throwing an error I can catch and swallow. If I can't store it, then I don't want my app to crash.

service name starts with $?

I noticed this module uses $service, it is angular's tradition to preserve $ for its own modules, is it possible to rename it something like localStorage or storage?

storage.bind() doesn't work inside factory

storage.bind() doesn't work inside a factory, I assume because there is no scope.

Passing an object doesn't work either:

app.factory('someFactory', function(storage) {

    var settings = {
        foo: 'bar',
        lorem: 'ipsum'
    }

    storage.bind(settings,'foo');
});

This produces the error undefined is not a function at Object.publicMethods.bind

Empty value in localStorage through bind function

Hi, thanks to your library pretty useful actually !

A thing that I don't really understand in bind function it's this statement :

    def = def || '';

when you define a defaut value like 0, null, or false it is transformed into an empty string in localStorage.

Bug when stored value = false

If you store the value false, the module will detect it as being not set:

// If a value doesn't already exist store it as is
if (!publicMethods.get(storeName)) {
    publicMethods.set(storeName, opts.defaultValue);
}

I propose the following fix:

// If a value doesn't already exist store it as is
if (publicMethods.get(storeName) === null) {
    publicMethods.set(storeName, opts.defaultValue);
}

Binding doesn't seem to be working for me

Great tool, but I can't get the binding to work.
I have several controllers and services and I'm using the angularLocalStorage to maintain state in SPA using angular ui-router.
The controller binds to a local store key. When a service sets the value in the local storage the bound value in the controller is not updated. They are updated on a hard refresh. I expected the bound values to update in the controller when the angularLocalStorage set function was called.

bower install not working

Added
"Angular-localStorage": "latest"
to my bower.json file.

It install fine into 'bower-components/Angular-localStorage'

However, the error is:
Error: [$injector:modulerr] Failed to instantiate module app due to:
[$injector:modulerr] Failed to instantiate module localStorage due to:
[$injector:nomod] Module 'localStorage' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

I've included the module correctly, as I've used the src file directly and is now trying to switch over to bower.

I'm not sure what I'm doing wrong but the localStorageModule.js doesn't look the same to the file in the src directoy.

Any help appreciated, thanks

Capture localStorage events

Hello, would be nice if the module can $broadcast / $emit events based on changes to localStorage, or capture storageEvent on window. This is for notification purposes, without needing a separate $watch somewhere else. Thanks.

NuGet package

Hi,

I was looking in Nuget but I can't find this package, under what name is it posted?

Thanks!

Public get/set/remove methods will execute localStorage code if $cookieStore method cause exception

For the public get(), set() and remove() methods, if supported == false and any type of exception occurs, the code specific to localStorage will attempt to run, even though supported == false.

For example, this is the current set():

set: function (key, value) {
    if (!supported) {
        try {
            $cookieStore.put(key, value);
            return value;
        } catch(e) {
            $log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
        }
    }
    // THE FOLLOWING LINES RUN WHEN THE CATCH(E) ABOVE IS TRIGGERED
    var saver = angular.toJson(value);
    storage.setItem(key, saver);
    return privateMethods.parseValue(saver);
},

Suggest doing the following:

set: function (key, value) {
    if (!supported) {
        try {
            $cookieStore.put(key, value);
            return value;
        } catch(e) {
            $log.log('Local Storage not supported, make sure you have angular-cookies enabled.');
        }
    }
    else { // THIS CODE WILL NOW ONLY EVER EXECUTE IF (supported)
        var saver = angular.toJson(value);
        storage.setItem(key, saver);
        return privateMethods.parseValue(saver);
    }
},

Using with app's that are coded using controller as syntax

I was looking to update an existing app to use local storage.

This app is written consistently with "Controller as namespace" in the views and no use of $scope in the controllers themselves.

So - e.g. given that a controller exposes

this.dataObject = {}

Is there a good approach to binding that two-way into localstorage without having to re-write everything back to $scope injection on the controller?

Updating local storage

i have a a question ,when my app is working offline ,when offline i fill out few changes
,how do i sink this data when the user is online ..

can i use $scope.viewType = 'ANYTHING';

will this serve my purpose or shud i explicit write a function to write into a variable and pushing to local storage and then getting the data and updating the my LS..

bower name: Angular-localStorage

Could you please update the bower name to "Angular-localStorage"? I can see the name "angular-localStorage" in README and bower.json, Thanks for sharing such good library.

Feature Suggestions

Nice library! :)

Two suggestions:

  1. Specifying a watch on a property in localStorage, so that if that property changes, the scope model changes as well. This is useful when using localStorage to sync the state of your app across multiple browser windows.
  2. An option to select how to resolve conflicts on binding. For example, when binding a property on the scope to a localStorage property, if both exist and have different data, you might want to choose which takes precedence. (IE which of the different values is "true", the localStorage one or the scope on)

bad url in bower registry

bower install angular-localStorage results in:

bower cloning git://github.com:agrublev/Angular-localStorage.git
bower caching git://github.com:agrublev/Angular-localStorage.git
bower error status code of git: 128

There were errors, here's a summary of them:
- angular-localStorage status code of git: 128
fatal: Unable to look up github.com (port agrublev) (nodename nor servname provided, or not known)

somehow the slash before your username became a colon.

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.