-
Notifications
You must be signed in to change notification settings - Fork 462
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
Saving to storage and redirecting results in storage not being updated (zero $timeout doesn't help) #124
Comments
You could use the |
@egilkh Unfortunately, it doesn't work:
It behaves exactly as without the $sync(). And looking at the source code of $sync(), it looks like it just reads the contents from localStorage, not writes it back? |
Indeed. Too early and no coffee. My bad. Maybe get/set should be added to enable this type of functionality. Or extend $sync with a write as well. I'm in the process of doing some refactoring to enable a few of the things discussed (in other issues or PRs) and I'll keep this in mind. |
@egilkh Thanks! Having more control in these corner cases (like having explicit get/set) would definitely help! |
Use $apply() to force a write to the storage. |
|
I have 2 routes with different templates / controllers, I have this code in first controller:
The first time editVideoTemplate is run videoTemplate gets saved in localStorage, but on consequent runs (selecting different videoTemplates) it fails to update the value in localStorage. So after initial save, EditorCtrl always gets initially saved videoTemplate from localStorage.
If I add 300ms timeout (instead of zero), it works as it should - videoTemplate gets saved and successfully retrieved every time.
Can we have direct setters / getters for these edge cases, when there's no point to force user to wait and force digest cycle?
The text was updated successfully, but these errors were encountered: