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

Setting to empty string, then to a non-empty string does not work #58

Open
roldengarm opened this issue Aug 20, 2018 · 2 comments
Open

Comments

@roldengarm
Copy link

roldengarm commented Aug 20, 2018

This is my service:

@CookieStorage({key: 'iso-language'}) private _isoLanguage: string;
public getIsoLanguage() {
  return this._isoLanguage;
}

public setIsoLanguage(language: string) {
  this._isoLanguage = language;
}

When I run setIsoLanguage('test') it works fine, getIsoLanguage() returns 'test'
However, when I run setIsoLanguage('') and then setIsoLanguage('test2'), getIsoLanguage() will still return the empty string.

Enabled debugging, but nothing obvious, it does show it's updating it.

When I set it to null instead of '' it works fine.

@MarkoSulamagi
Copy link

@roldengarm You need to set a default value for the variable.

@CookieStorage({key: 'iso-language'}) private _isoLanguage: string = null;

Not sure if it will fix your problem, but not setting it caused various unexpected errors for me.

@Moulde
Copy link

Moulde commented Sep 18, 2018

Yep, remember the default value on the property. I had some very weird issues when i forgot that as well.

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

4 participants