I'm facing a challenge with my module that has its own subrouting. The page only consists of a header and material tabs linked to my routing, with the need for the landing tab to differ between desktop and mobile.
To handle platform detection, I have a ToolService with a method called ToolService.isDesktopOrTablet() which I typically use.
Prior to wanting the redirectTo to point to 'list' instead of 'tree' on mobile, my routing module was structured like this:
insert modified code here
My initial attempt involved using a class-based guard, but I discovered that Angular 15 deprecated them in favor of functional guards.
Next, I tried a functional guard but encountered a warning about canActivate conflicting with redirectTo since redirects are processed ahead of guards.
So, I turned to another solution - a resolver:
insert modified code here
Although no error is triggered by this approach, it also doesn't seem to have any effect. When I navigate to the main route, the app remains on the '' route without redirecting as if the resolver wasn't executed. This leads me to these questions:
- Is there an issue with my resolver?
- Is a resolver suitable for this task?
- If so, what am I missing?
- If not, what alternative should I consider? Should I have persevered with guards?