Open thinkOfaNumber opened 6 years ago
I am struggling with this issue too. The application I'm developing uses child routers heavily to support sharing and bookmarking deep links. I'd love to be able to use fallbackRoute on child routers to get users as close to what they needed as possible, even if the enitity deep down in hierarchy doesn't exist anymore. Any chance of a fix?
I'm submitting a bug report
I'm fairly certain this is a bug. At least it's very surprising and there doesn't appear to be a way to use fallback routes in child routers.
Please tell us about your environment:
Operating System: Windows 7
Node Version: 6.11.4 and 8.6.0
NPM Version: 4.4.4
JSPM OR Webpack AND Version webpack 2.5.0
Browser: Chrome 61.0.3163.100
Language: TypeScript 2.2 / ES6
To reproduce:
config.fallbackRoute()
)see also this gist run.
Expected/desired behavior:
I would expect that the fallback route is chosen based on matching the location to the child router, and choosing it's fallback route.
Actual behavior: It seems that only the root router's fallback route is used. If the root router has no fallback route (but the child router does), I get the error: "Router navigation failed, and no previous location or fallbackRoute could be restored."
(edit) Also, my research found some issues but I think they're not related:
I'm currently working around the issue by calling
return new Redirect(this.router.generate("something"));
fromcanActivate()
instead.