I'm trying to do a simple task in Angular but it's giving me some trouble.
I have 2 separate components with no relation between them, let's call them Component A and Component B - all I want is that when I press a button in Comp A to run a function in Comp B - the onClick event and corresponding function is already sorted, I just need to call a function that's coming from Comp B like in the example below:
Component-A.component.ts
onButtonClick() {
//do something
//call function from Comp B
functionB();
}
Component-B.component.ts
functionB() {
element.scrollTo({top: 0})
}
All I want is to call the function from Comp B inside the onClick function of my button from Comp A so that the container of Comp B is scrolled to top.
What would be the simplest way to achieve this? Thank you in advance!