Giter Club home page Giter Club logo

Comments (16)

egilkh avatar egilkh commented on August 20, 2024 1

I noticed this and will be looking into it. I didn't seem to have this problem when I used an object (which is how I usually use $localStorage). Ex:

$localStorage.awesome = { key: 'value' };

In which it seemed more consistent. Will look into it.

from ngstorage.

pruthvim96 avatar pruthvim96 commented on August 20, 2024 1

i have same issue regarding this local storage first i have x value when i go to previous page and get y value i am getting y value.but, i need to be displayed with x and y value

from ngstorage.

akizor avatar akizor commented on August 20, 2024

Same here

from ngstorage.

milushov avatar milushov commented on August 20, 2024

I have similar issue: $localStorage contain my value, but localStorage does not

from ngstorage.

emiidee avatar emiidee commented on August 20, 2024

Same: localStorage saves value a, at some point I update it to value b (this works), then when I refresh it goes back to value a

from ngstorage.

SlashingEdge avatar SlashingEdge commented on August 20, 2024

I'm having the same problem as emiidee, it does update to new value but it keeps giving the old value when I refresh, why is that?

from ngstorage.

egilkh avatar egilkh commented on August 20, 2024

@SlashingEdge could you try using master ngStorage.js and provide a snippets where this happen for me to test? :)

from ngstorage.

egilkh avatar egilkh commented on August 20, 2024

As the plnkr doesn't seem to work, anyone that can confirm this still is a issue?

from ngstorage.

 avatar commented on August 20, 2024

Same here, updating $localStorage.token every 30 mins. The value remains the same.

from ngstorage.

bdkent avatar bdkent commented on August 20, 2024

I notice the behavior described above where updates stopped working if I have multiple $localStorage.$default({...}); calls with different defaults in different angular components.

For example, if ServiceA has var $storageA = $localStorage.$default({ a: "foor"}); and ServiceB has var $storageB = $localStorage.$default({ b: "bar"});.

I got around this by making my own service wrapper with a var $storage = $localStorage.$default({ a: "foo", b: "bar"});. Then the wrapper service had a method to getA() and getB().

Note sure if this is a correct usage, but it got around the issue for me.

from ngstorage.

egilkh avatar egilkh commented on August 20, 2024

Thanks bdkent for the reports.

There should be no need to make extra services. And I'll continue working on it. But sadly my time has been limited these last weeks. But I'm still here and will have more time soon :)

from ngstorage.

RolandHeath avatar RolandHeath commented on August 20, 2024

I found that for me this was an issue with $localstorage.$default.

My workaround was to replace
x = $localstorage.$default({a: "foo"})
with
x.a = $localstorage.a || "foo";

This seems to restore the expected behaviour, having replaced $default everywhere in my code.

from ngstorage.

egilkh avatar egilkh commented on August 20, 2024

Thanks. Seems the whole of $default is a little screwed up.

from ngstorage.

omarmeky avatar omarmeky commented on August 20, 2024

+1

Current workaround: $localStorage.a = $localStorage.a || 'foo';

from ngstorage.

emanuel-virca avatar emanuel-virca commented on August 20, 2024

I've faced a similar issue and it happened because I was setting item using localStorage.setItem(key value) and tried to read data using $localStorage.key which, of course is not ok. I used localStorage.setItem because of the need to immediately catch QuotaExceededError. The fix was to read data using localStorage.getItem or call $localStorage.$sync() to sync the ngStorage with native localStorage .

from ngstorage.

avimatrix avatar avimatrix commented on August 20, 2024

Same: localStorage saves value a, at some point I update it to value b (this works), then when I refresh it goes back to value a

you can call a method in respective service regarding to localStorage like getRole(),getToken()..it return localStorage.getItem('key')
so in your template(.html) ,you can call directly like authService.getToken() it returns updated value only.
Before that you can provide dependency injection in your component.
It works...

from ngstorage.

Related Issues (20)

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.