marcj / angular2-localstorage

Angular 2+ decorator to save and restore variables/class properties to HTML5 LocalStorage automatically.
302 stars 107 forks source link

The library is not using actual localStorage #43

Closed v3rron closed 8 years ago

v3rron commented 8 years ago

I'm using a library angular2-jwt which relies on localStorage object. After setting a @LocalStorage value, it's not actually setting anything on window.localStorage, but based on source code, if I understood correctly, it's using custom object for storing the values. I think the name of the package is misleading, since people would assume it uses window.localStorage which I'm sure lots of libraries depend on.

This package is really great, but is it possible to use actual window.localStorage? Thanks in advance.

v3rron commented 8 years ago

Sorry, my bad, it actually uses localStorage, it's just somehow added a backslash in front of the variable, that's why it was returning null.

@LocalStorage id_token: string;

This line was actually setting /id_token variable. Don't know how that happened, but I fixed it with:

@LocalStorage('id_token') id_token: string;