Im trying to pass variables between two components - they are not parent/child components. I have a file named input.ts with a input.html file where the user types in their input. The values he/she inputs are then pushed into an array inside the input.ts file. I want to be able to access this variable (with pushed values) in another component (calendar.ts and calendar.html), as that is the place where I need to manipulate and push the values into the calendar. I've read that you can use services but it seems rather complicated. Is there a simple way to do this in angular/typescript?
I've tried doing it like below, but with no success unfortunately.
I hope someone could please help me.
Many thanks, and much appreciated!
class InputComponent {
inputtedValuesArray: string[] = []
}
import {InputComponent} from '../input/input.component'
class CalendarComponent {
generateCalendar() { //function just to see the values inside.
for (let i of inputtedValuesArray) {
console.log(i);
}
}