0

As I am getting deeper into Angular, im trying to implement the following situation, these are my components:

What I am trying to figure out is the ideal way of passing data from a child to the parent and some other component. I am able to do it with @Input() and @Output() decorators but I am wondering if its the right way and what if there were more components in between? I tried using services too but couldn't update the data properly. What would be a better approach to this?

Atakan Bal
  • 27
  • 7
  • 1
    Here is an article of some technics to share data between components : https://medium.com/front-end-weekly/sharing-data-between-angular-components-f76fa680bf76 – Emilien Aug 25 '20 at 14:09
  • 1
    `"I tried using services too but couldn't update the data properly."` ← Also a perfectly good way to share data. What was not working in this scenario using a service(s)? There are also plenty of previous questions on [so] about sharing data between components, what have you tried that is not working? – Igor Aug 25 '20 at 14:11
  • @Igor After spending some time trying to figure out what is wrong with my services, it turns out that I had the service declared as a provider on the child component (vis-selection) so that service was doing its own thing. What caused this behavior? – Atakan Bal Aug 25 '20 at 16:54
  • 1
    Did you make sure they were registered as singletons? See https://angular.io/guide/singleton-services#using-providedin – Igor Aug 25 '20 at 17:05

0 Answers0