I recently started working on Angular (Angular5). My application has tabs named Home, School, Office and I have two types of users Admin and non-admin. As soon as the Office tab is clicked Admin page will be redirected to Admin page and non-admin user will be redirected to non-admin page.
So, for this requirement do I need to make two different modules? OR shall I make a single module and redirect on the bases of user types? Please guide me with the project structure.
Modules are not separated by roles of your application - Separation of modules is the process of separating your code based on no complexity if in case you have a
componentthat need to be used in multiple places you can move that component to asharedmodule andimportthat module into all your sub modules - if you want to load a module Lazily you can work on loading a module LazilyIn your case - the word is
routefor you - you can check whether the user hasadminornon-adminwhile routing, that can be achieved by usingResolverwhich does magic for you - check this link for further queriesTry something like this
Router
RolePermissionService
So the return data will bind to the
RolePermissionobject in your route and finally you can read it in yourcomponentComponent
In you component you can read that data like this
this._activatedRoute.snapshot.data["RolePermission"].ISSubmitSlotRequest;So this will solve your problem you can map this service to all the routes you want and you can get the role of the user - I'm not against module creation this will be a better way to read the roles on routing - check that link for more idea - Happy coding :)