Closed syska closed 3 years ago
Hi @syska, This isn't an issue with the library. The directive was created to set UI elements properties from localstorage.
What's your actual use case? Have you tried refactoring the provided example using the provided decorator on the property (ngModel binding staying) instead of using the directive?
@bohoffi
I have a component which is reused on multiple pages with different settings. Also the key
which is used to specify what the value should be saved in local storage under.
For now I have just used the LocalStorageService
directly and my own logic.
So I guess the directives is mostly used when getting the data directly from the form and not though bound properties.
I will try the decorator
for other properties that is always needed to be saved in Local Storage, when I get to the other part of the application ... specifications are not in place yet.
Still love the package ...
Hey @syska,
'...Also the key which is used to specify what the value should be saved in local storage under....' I may miss something but I don't get what you want to do. What do you want to store additionally?
Maybe I should update the docs on the decorator and directive to be more clear about how they work.
The directive
is made to 'two-way bind' a localstorage value to a UI element so the stored value can be considered as the elements backing field.
The decorator
two-way binds a stored value to a property directly.
If this clears up your questions please let me know so I can close this issue.
'...Also the key which is used to specify what the value should be saved in local storage under....' I may miss something but I don't get what you want to do. What do you want to store additionally?
I have a shared search component ... search-box-component
... depending on where it's used, I want to save the value under different names, or lsKey
as used in this package.
So when the user goes back to users-list-component
that uses search-box-component
... I can set the name so I can reuse my logic/components instead of copy/pasting ...
Thats the reason i needed this ... now I just have an @Input()
decorator to set the key
being used and then uses the LocalStorageService
to fetch the value.
Maybe I should update the docs on the decorator and directive to be more clear about how they work. The
directive
is made to 'two-way bind' a localstorage value to a UI element so the stored value can be considered as the elements backing field. Thedecorator
two-way binds a stored value to a property directly.If this clears up your questions please let me know so I can close this issue.
This clears it up ... I might try the Decorator
later to night ...
Describe the bug
https://stackblitz.com/edit/angular-ivy-hdgjx6?file=src%2Fapp%2Fsub-module%2Fsub-module.module.ts
To Reproduce Steps to reproduce the behavior:
Value: {{ textModel }}
Expected behavior I would expect the property in the component to be updated with the value set from the directives.