RedirectTo not working with canLoad of @lifecycleHooks. If you comment canLoad function, redirectTo works. Could someone help me, please?
@Sayan751 sorry for the tag. The problem is async canLoad, could you see this?
Hi @DanieleRosada! Can you please elaborate a little bit more, what exactly isnāt working? I have forked your example, and it seems to be working.
I see two behavioral patterns in āasync canLoad" and "canLoadā, a function of lifecyclehook component. In the first case, redirectTo is in the middle state and by that I need to press Dashboard link to see the child viewport. In the second case the redirecting is automatic.
I need to understand if that is the right way to use redirectTo or if it is a bug.
Sorry. I have missed the obvious point.
I have tried your example with @aurelia/router-lite
: discourse 5055 - StackBlitz. It seems to be working as expected. If your routing needs are limited to configured routing or if your project is not yet coupled with the @aurelia/router
, you may once give the @aurelia/router-lite
a try.
As for why it is not working for @aurelia/router
, I am not sure. @jwx maybe something is missed in the example?
Iām back after one week of trial with @aurelia/router-lite. It works well, nice job.
Hereās a list of doubts I still have:
BUGS
- history.back() not always working (DEMO: bug history.back() - StackBlitz)
- field isActive in @IRouteContext isnāt true when I use redirectTo
QUESTIONS
- Why routes like this {path: āā, redirectTo: āhomeā} are inside @IRouteContext.navigationModel.routes?
- Why, if I use @IRouter router.load() in the same class of routes defined, do I need to pass the current context?
Thank you for trying out router-lite!
- history.back() not always working (DEMO: bug history.back() - StackBlitz)
The bug is already been fixed, and the fix is available under the dev
tag. If you remove your package-lock.json, save and reload (this will regenerate the lock file), you can see it to be working. Here is a working example: bug history.back() (forked) - StackBlitz.
- field isActive in @IRouteContext isnāt true when I use redirectTo
Do you mean the @IRouteContext.navigationModel.routes[i].isActive
? If yes, then I have probably missed something. Thank you, reporting this. I will take a look. A temporary workaround might be to use an array of paths instead of redirectTo, depending on your use-case.
- Why routes like this {path: āā, redirectTo: āhomeā} are inside @IRouteContext.navigationModel.routes?
This is like the NavModel
(available via router.navigation
) in Au1 (Au1 docs). The Au2 docs explains this.
- Why, if I use @IRouter router.load() in the same class of routes defined, do I need to pass the current context?
This is because the IRouter
instance in router-lite is singleton. And when you donāt specify a routing context, the default is always the root context. This is documented here.
The bug is already been fixed, and the fix is available under the
dev
tag. If you remove your package-lock.json, save and reload (this will regenerate the lock file), you can see it to be working. Here is a working example: bug history.back() (forked) - StackBlitz.
Youāre right, sorry.
Do you mean the
@IRouteContext.navigationModel.routes[i].isActive
? If yes, then I have probably missed something. Thank you, reporting this. I will take a look. A temporary workaround might be to use an array of paths instead of redirectTo, depending on your use-case.
Yes I mean this.
Thanks for the documentation links
The isActive
issue with the redirectTo
should be fixed now. The fix is available under the dev
tag. For more information, you may refer the PR.