Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is removed after refreshing page #77

Open
maxipeli opened this issue Apr 27, 2019 · 1 comment
Open

Data is removed after refreshing page #77

maxipeli opened this issue Apr 27, 2019 · 1 comment

Comments

@maxipeli
Copy link

Hello,

I am just trying the library, because it seem very interesting. But I am having some problems.

Everytime I refresh my page, all the localstorage is removed. Maybe I am doing something wrong. This is my component:

 `import {Component, OnDestroy, OnInit,} from '@angular/core';
  import {LocalStorage} from 'ngx-store';
  
  @Component({
      selector: 'app-test',
      templateUrl: './test.component.html'
   })
   export class TestComponent implements OnInit, OnDestroy {

       @LocalStorage() data = 'none';
       
       constructor() {}

       ngOnInit(): void {
             console.log(this.data);
             this.data = 'mydata'; 
       }
       ngOnDestroy(): void {}
   }` 

It is a simple component only to try the decorator feature. I am using the default configuration. When I refresh the page the variable 'data' is removed from localstorage, and before removed it, for a second in localstorage appear a variable called NGX-STORE with the value 'ngx_' (default prefix). Could you help me telling me what I'am doing wrong?

Angular version: 7.2.0
ngx-store version: 2.1.0

Thanks in advance!

@DanielKucal
Copy link
Member

Hi @maxipeli, can you check if @LocalStorage() data = ''; will also replace previously set value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants