I am using mgechev's angular2 seed for my project. I am working on Angular2 for last 6 months (following the world with all the RCs to Final release). I am stuck with a requirement my client has. I wish you guys could help.
Here is the problem. Base on user role:
ROLE_ADMIN
ROLE_REVIEWER
Web app should be able to load specific modules and display. Say,
- if user role is
ROLE_ADMIN
then load angular2 modulesModule1
&Module2
- if user role is
ROLE_REVIEWER
then load angular2 modulesModule1
only.
When I say load, it means it must fetch the module files (everything that is bundled with the module) from the server, inject into Angular2 app and display that module.
So, if the user role is ROLE_REVIEWER
I shall be able to see only Module1
that means Module2
should not be even fetched from the server.
EDIT
Here is difficult part, url is not changed while doing it. Consider this module as widgets which loads on your dashboard /dashboard
. Thus no url change is expected while loading these modules.
Hope my question is explanatory enough. Please suggestion what all I should do or research or study to achieve this.
My best guess, I have to do the following:
- Conditional lazy loading (without routing) & then,
- Dynamic Loading
But I do not know how.