Here i want to communicate between two components of a same parent.Basically,i want to pass the data from one component to another.
FirstComponent.ts
constructor(
private service: service1,
private serve: service2,
) {}
ngOnInit() {
this.service.getUser().subscribe((data) => {
this.serve.setAccount("1", "apple");
this.serve.setEnvironment("Happy");
})
}
SecondComponent.ts
constructor(private usingService : service2) { }
ngOnInit() {
this.Account = this.serve.getAccount();
this.environmentDetails = this.serve.getEnvironment();
}
I need to retrieve data from firstComponent to second.here first component is loading after the second component.soo,the data set by first component comes later by in picture.
Tried using subject of rxjs.but,How can we use subject in firstComponent.ts of this example?
How i can communicate between these two components being they are siblings of each other?please help