DEV Community

Discussion on: Component Interaction in Angular

Collapse
 
stradivario profile image
Kristiqn Tachev

What you are describing here is totally a bad practice and no one should use it.

To interact with parent component via child component is making too much coupling and actually it creates unreadable code.

I didn't saw not even one observable here why?

In the service you should have observables and the component should subscribe with async pipe instead relying on Zone change detection mechanism.

If you now change the strategy of the component to OnPush you will end up with broken and not working code.

I recommend you also for advanced architectures ngrx to be used with Facade pattern.

Regards!

Collapse
 
ankit_k_sharma profile image
Ankit Kumar Sharma

Thanks for your valueable feedback.
I create it more simplely, also try it for freshers, who can easily understand , what is component interaction in angular, then they can use observaables, services as per their requirements. We can use observables as well and services. Also ngRx (State Management) is a different thing, it is for how we can manage state in angular, here I am explaining angular component interaction. for NgRx (State Management) will write another article.
Thank you again for your feedback.
Keep smiling