0

I am working in Angular 7 . where I am passing object to another component , I am doing it using @input decorative , but components are siblings , so How I can pass the object to another component

1

2 Answers 2

1

It is better use Service for the communication in this scenario.

In service u can use Subject which can act as both observer and observable.

ex.

In Service

  someSubject = new Subject<any>();

In component one

 someService.someSubject.next(objectUWantToSend);

In Component two u can subscribe or vise versa

someService.someSubject.subscribe((receiveObjectHere) => {});
Sign up to request clarification or add additional context in comments.

Comments

0

@input decorative can only be used for passing values from parent to child components.

For communication between siblings or any components use rxjs subject and Observable instead.

You can follow this - http://jasonwatmore.com/post/2018/06/25/angular-6-communicating-between-components-with-observable-subject

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.