When using child routes with angular2's router "3.0", there is no need to declare them in the parent router config (before, you had to do something like /child...
in the parent component).
I want to configure a global "page not found" handler, which I can do like this:
{ path: '**', component: PageNotFoundComponent }
in my app routing module.
The caveat: If I do this, the router navigates to routes declared in the app routing module before the PageNotFoundComponent
just fine. But it always navigates to the wildcard route when I try to access a child route (declared using RouterModule.forChild
in some child routing module.
Intuitively, the wildcard route should be placed behind all other route configs, because the router resolves in declaration order. But there does not seem to be a way to declare it after the child routes. It also does not seem very elegant to declare a wildcard route in all child router modules.
Am I missing something or is there just no way to define a global 404-page in Angular-2-Router-3 when using child routes?