DEV Community

jalpesh Vadgama
jalpesh Vadgama

Posted on

1

Angular: Interaction between Component with Shared service

In this video, We are going to learn how we can have interaction between components via shared service.

If you have not seen my first video about Interaction between Component with @Input and @Output in Angular and then I would highly recommend it to see that video. Following is a link to that video.

https://bit.ly/AngularComponentInteraction

In this video, I have created a shared service that has got a message source as behavior subject from rx.js which holds an observable. By default, I have initialized it as the default message. Then I have created a new method where I have created a method called "change message" from where the user can change the message.

After that, I have injected this service into two different components and subscribe to current message observable. I have also created a button click event in both components which calls the Change message method from shared service. As we have subscribed to both our message observable it will reflect in message change in both components.

Source Code for this video is available on - https://github.com/JalpeshVadgama/AngularSharedService

If you like this video and wanted to see a similar kind of video then, please subscribe to my youtube channel at - https://bit.ly/codewithjv.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up