I know that Aurelia route modules can be specified dynamically using navigationStrategy
but that does not work for my purposes because the toggle value resides in the RouterConfiguration that only runs once. I need a way to route to different views where the toggle value can change multiple times during one session. Additionally, not all routes have multiple views.
What is the best practice for routing to different views on the same route based on a dynamic value?
I've come up with a few different strategies but I'm not sure which one is the most acceptable way to do this.
Using
viewPorts
where the route will have a staticmoduleId
to a view that injects the name into an instance of<router-view name="view1_index"></router-view>
using a global string, e.g. 'view1' may be passed down as 'view2', etc.Using 2 or more instances of
<compose>
where the route will again have a staticmoduleId
to a view that will use a global variable to toggle anif.bind
in the<compose>
instancesUsing
canActivate
in the route module and redirecting to the secondary viewport if conditions are metUsing a pipeline step in the router config to evaluate whether it should direct to a different module (if this is possible)
Which of these strategies, if any, is most accepted? If all of these are odd ways of routing to different views per route, what should be done?