Skip to content
Advertisement

Angular 404 page routing for nested modules

I’m Using nested modules in my project

JavaScript

In the main route I only configured top-level routes:

app-routing.module.ts

JavaScript

Separately, I configured routes separately in each sub-modules, like:

mall-routing.module.ts

JavaScript

The result is, because that no other routes are defined in the main routing configs, all requests other than login/register/404 will be redirected to 404.

Is there anyway I can use a correct 404 redirection but keep the current route file structure? I don’t hope to gather all route configs together.

Thanks!

Advertisement

Answer

import the ‘Other’ modules in your app modules, this will allow the routes defined in those modules to be used.

The updated code should look something like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement