#Issue with checking for update observer
14 messages · Page 1 of 1 (latest)
Right now the situation is - i add person to the dashboard, but nothing happens. When i swap routes and return to the page, the info loads just fine
i looked at the lifecycle methods but i dont think there is really a way to do what i am trying to do
Maybe it is a routing issues, if i manually route to the page it works fine
You subscribe to this.consultantService.data$, but you don't do anything with the received data. You need to set the input to the component every time it changes.
is this not done through newComponenetRef.setInput("body", this.data) in the rendering function?
That is done once, when you create the component. But the data is emitted several times after that, so every time it changes, the input must be set again. It seems you're a newbie. Why are you creating components dynamically that way? Why don't you use the template and let Angular create components for you?
"But the data is emitted several times after that, so every time it changes, the input must be set again." what do you mean? i use a eventEmitter to add a person to a observable, will this be done multiple times?
and im creating a dashboard with "widgets" template components which can be added through a add Widget component
and yeh i would still call myself a newbie 😄
An observable is used to represent a flow a values being emitted over time, usually asynchronously. Every time you call setConsultant() on your service, the observable emits a new data.
Since this data is supposed to be passed as input to your components, you need to do it.
so from the subscribe function i would need to clear the references and rerender with the new inputs?
No. You would need to call setInput() on your components.
ah i see