I am struggling to pass the content of a variable from one component to another in Angular. The two components are on different pages and not directly related, but I need to access the value of the variable in the second component's TypeScript file without displaying it on any page. Despite trying various tutorials, I have not been successful and feel lost about how to proceed.
The code snippet below is located in p1_week-chart.component.ts:
else if (chart.data.labels[activeEls[0].index] == "Wednesday") {
this.dayClicked = new Date(this.today);
this.dayClicked.setDate(this.dayClicked.getDate() + 2);
console.log(this.dayClicked);
//seeking to send the content of this.dayClicked to the other component (p1_day-chart.component.ts)
Extra information: I only require TypeScript for this scenario, no HTML elements needed.
Any assistance would be greatly valued!
(Despite experimenting with several solutions such as BehaviorSubject, I am unable to successfully transmit the content of this.dayClicked to the p1_day-chart.component.ts file. While I've seen similar queries raised here, none of the suggestions have resolved my issue.)