I want to show pages with custom slugs in my Angular app and have managed to do that by adding a wildcard-route with a CanActivate guard that checks if the current browser path is a slug associated with a page in the CMS:
{
path: '**',
loadChildren: './modules/content-page/content-page.module#ContentPageModule',
canActivate: [IsContentPage]
}
The app loads the ContentPageModule if the page is found but now I'd like the app to show a 404 page if the page was not found. Preferably the URL would stay the same so I don't want to redirect from within the IsContentPage guard. Adding another wildcard route without a guard does not work:
{
path: '**',
loadChildren: './modules/not-found/not-found.module#NotFoundModule'
}
With these two routes declared, the app just shows a blank page after the IsContentPage returned false. If the NotFoundModule-route is declared before the ContentPageModule-route, then that one is always fired.
I'm using version 5.2 of Angular Router.
Could someone help me any further? How should I tackle this problem?