I created a behaviour subject in a service class.
public personObject: BehaviorSubject<any> =
new BehaviorSubject<any>({ personId: 1, name: 'john doe' });
On a component that imports this service, i subscribed this behaviour subject like this:
this._subscription.add(
this._bankService.personObject.subscribe(data => {
this.personObject = data;
console.log(data);
})
);
But I am not able to get exact dataset in the behaviour subject.
Edit I forgot to mention that I used ViewContainerRef to create my sibling component which I added to an answer with a few comments.