L
L
lMoJlo4HuKl2018-05-17 16:39:56
Angular
lMoJlo4HuKl, 2018-05-17 16:39:56

How to implement two-way bindings between a component and a service?

There is a service in which an object is created based on data in LocalStorage, for example. I call getData in the component, I get the data, after changing the data in localStorage, without refreshing the page, the data does not change. how to implement it? I am using angular 6. (I know that in angular 1.6 this is possible, but implemented in the same way, it does not work)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
denismaster, 2018-05-18
@denismaster

Use NgRx or a common data bus based on RxJS Behavior Subject.
In a component, you subscribe to state changes.
You can also use the event onstorageto update components in other tabs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question