In my Angular app, I have a FAQ component located in the app.component.html
file, positioned next to the Router Outlet as shown below:
<div class="site-container">
<router-outlet></router-outlet>
<app-callback></app-callback>
<app-faq></app-faq>
</div>
One of the routes leads to .../question which displays a question component. When a question is answered within this component (by clicking a button), I want to update a variable in the FAQ component.
answerQuestion(id: string) {
// Answer question coding...
faq.faqDisplay = false;
}
This code snippet modifies the value of a declared variable in the FAQ component to false.
export class FaqComponent implements OnInit {
faqDisplay = true;
}
Initially, I considered using @Input()
or @Output()
, but due to these components being situated side by side rather than being directly related as parent and child, I faced challenges implementing this approach.
While there are resources on passing data between parent and child components, solutions for communication between side-by-side components seem scarce. Is there a method to achieve this type of communication, or perhaps an alternative solution?