Is there a built-in method for routing multiple possible links to the same "page"?
For example, I have a '/' route that loads a landing page by binding the active attribute of that route to a property named landing-active, which is being observed. The most straightforwards way I can think of to allow converging routes is to create another app-route element for the new route, and bind its active attribute to the same landing-active property as the '/' route.
Is there a better/different way of handling this, or should I stick with my method?
Edit : I tried my method out, and it doesn't work. Here's my original route:
<app-route
id='landing-route'
route='{{route}}'
pattern='/'
active='{{landing-active}}'>
</app-route>
If I then add an alternate route by simply changing the pattern and id, then the '/' route no longer works. Changing the active binding on the new route fixes this issue, but also no longer allows it to rout as intended. So my conclusion is that I can't bind the same property to the active attribute of two separate app-route elements, so my routing method doesn't work.
What alternatives do I have?
Option 1: Use two separate active
variables for your two <app-route>
s, and test for either variable (eg, with a computed binding / property ).
Option 2: Use a different router component. <nebula-routing>
might be the best option IMO, given that it has a similar API to <app-route>
and supports regular expression in the route patterns.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.