Currently, I am utilizing a service to transfer data between components. The code snippet for my component is as follows:
constructor(private psService: ProjectShipmentService, private pdComp: ProjectDetailsComponent) {
}
ngOnInit() {
this.psService.getTDate().subscribe(x => this.cachedResults = x);
this.populateArrays();
In this setup, the service looks like this:
constructor(private service: DataService, private pInfo: ProjectDetailsComponent) {
this.rProjectNumber = this.pInfo.rProjectNumber;
this.rProjectSO = this.pInfo.rSalesOrder;
this.entityUrl = this.pInfo.entityUrl;
this.tDate = service.get<ShipDateFilterModel[]>(this.entityUrl);
}
Although the tDate contains data within the service, when subscribing in the Component, the cachedResults variable remains empty when the service is called during the ngOnInIt lifecycle hook. What could be causing this issue?