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

Using ngxLocalStorage in sub module ... complains about lsValuePath not being a known property #32

Closed
syska opened this issue Nov 6, 2020 · 5 comments · Fixed by #33
Assignees

Comments

@syska
Copy link
Contributor

syska commented Nov 6, 2020

Describe the bug
Simple test run of the ngxLocalStorage directive from https://bohoffi.github.io/ngx-localstorage/ -> Directive:
<input type="text" id="txt1" ngxLocalStorage lsPrefix="demo" lsInitFromStorage="true" lsEvent="input" [lsValuePath]="['value']"/>

Just pasted into a component which in defined in a module called ParthnerSharedModule

Can't bind to 'lsValuePath' since it isn't a known property of 'input'.

To Reproduce
Steps to reproduce the behavior:

  1. Add the module to app.module.ts.
  2. Use the above from the samples ...
  3. See error

Expected behavior
I'm really lost or really stupid here ...

The errors goes away if I import the module in my sub module ...

But when accessing the site I get Error: NgxLocalStorageModule is already loaded. Import it in the AppModule only

So ...

I use the LocalStorageService in one of my services which works fine.

I most be missing something here ... I can't be the first one doing to ... Please let me know if you need more information.

@bohoffi bohoffi self-assigned this Nov 6, 2020
@bohoffi
Copy link
Owner

bohoffi commented Nov 6, 2020

Hi @syska thanks for reporting. It seems like you are the first one doing this.

I'll take a look into this as soon as I can.

@syska
Copy link
Contributor Author

syska commented Nov 6, 2020

If needed let me know if you need a small repo of the issue.

Also, i should mention that some modules will be lazy loaded.

Thanks for the fast response.

@syska
Copy link
Contributor Author

syska commented Nov 6, 2020

Hi @bohoffi

Just created a small repo: https://stackblitz.com/edit/angular-ivy-hdgjx6?

Maybe it's a simply thing, maybe something needs to be changed to support this.

This shows the issues with a module having a component that is using the directives.

This is my first stackblitz usage to repo an issue, hope it's usefull.

bohoffi added a commit that referenced this issue Nov 6, 2020
This commit removes the default constructor and adds a static `.forChild` method.
@bohoffi bohoffi linked a pull request Nov 6, 2020 that will close this issue
1 task
@bohoffi
Copy link
Owner

bohoffi commented Nov 6, 2020

@syska I've published v3.2.1 which adds a .forChild() method when importing the module into (lazy-loaded) submodules.

@syska
Copy link
Contributor Author

syska commented Nov 6, 2020

@bohoffi

Holy smokes your the man. That was an extremely fast fix 🥰🥰🥰

I will go tests it later today.

It was purely luck i wanted to find a local storage implementation, that handled error cases etc. ... Then sat this feature to remember state in forms ... That was on the road map for the project ...

Not sure what it's actually called, I haven't found any other packages that does this ... But not needed since it was here 😁

Thanks a million.

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

Successfully merging a pull request may close this issue.

2 participants