E
E
egorggegor2021-01-26 23:15:43
JavaScript
egorggegor, 2021-01-26 23:15:43

How to render the changed information in Angular when changing data in localstorage?

Hello. I am writing a SPA application, how can I organize a page update when information changes in localStorage.
In html there is a form and a button, when the button is clicked, a string is sent from the form to the component function, how can I subscribe to this function so that when it changes, only that part of the page that is new is rendered.
How can I do that?

Thanks for answers !

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kovalsky, 2021-01-27
@egorggegor

It is enough just to add comments to an array and display this array in the template, then to display new comments, you will need to add them to this array

D
Daniil Vasilyev, 2021-01-27
@hello_my_name_is_dany

I would write a facade service through which the entry to localstorage will go, just using RxJs I subscribed to the entry event in localstorage, passing the key, and already in the subscriber in the controller, check the necessary keys and, if necessary, set new values ​​to the fields.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question