Hey there! I have a current component structure set up like this:
appComponent
--infoComponent
---beforeComponent
---afterComponent
Both the before and after components have navbars with unique IDs, specifically navbar_before
and navbar_after
.
Here's my first question: Is it possible for me to use JS/TS code in the infoComponent to dynamically load either the before or after component based on a certain condition, without directly including
<app-before></app-before>
or <app-after></app-after>
in the infoComponent? I want to assign this as a variable.
As for the second question: If the answer to the first question is yes, how can I access the navbar element with the ID of the before/after component from the infoComponent, similar to this example code:
var navbar = document.getElementById("navbar");
In summary, my goal is to create a sticky navbar with different menus as I scroll. Any helpful resources or guidance on how to achieve this would be greatly appreciated!