I have a multiple user Angular app, with a module for each user (because they have totally different accessible pages), like this:
- app.module.ts
- app-routing.module.ts
- login/
- admin/
- pages/
- user-management/
- configuration/
- admin.module.ts
- admin-routing.module.ts
- user/
- pages/
- task-management/
- configuration/
- user.module.ts
- user-routing.module.ts
- guest/
- pages/
- guest.module.ts
- guest-routing.module.ts
From the login page (/login
from app-routing), I want to redirect to each module based on the credentials the user provided, but NOT with children routes like /user
/admin
or /guest
Instead, when an admin logs in, I want the URL to be reset. So, for example, the admin should not see the paths /admin/user-management
or /admin/configuration
; it just accesses /user-management
or /configuration
Is this possible? Will it be a problem if I have a /configuration
route for both admin
and user
?
EDIT: Here's a Stackblitz working example. Take a look at the URL routes when logged in.
EDIT 2: In the Stackblitz example, you can see the original problem on master
and the working solution on solution
branches.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…