Dan
Dan

Reputation: 57881

A way split an Angular 4 app into user-facing and admin parts

I'm designing an architecture of Angular 4 app. The application will be used by two groups of users: "end-user" and "admin".

I don't want to split the code into two separate applications, because a lot of classes for end-user will also be needed by admins (for example, to preview changes). On the other hand, no classes for admin are required for end-user.

Of course, I don't want to ship scripts for admin to end-user. So I want to have two build plans: full and reduced. This is my vision of the solution, other solutions might be better.

Let me summarize the problem: I need a way to bundle code for end-user separately. But I don't want to have two separate projects for user and admin because of shared code.

What would you recommend to do?

Upvotes: 0

Views: 856

Answers (1)

Mauricio De La Quintana
Mauricio De La Quintana

Reputation: 2442

I would recommend dividing your app into 2 features modules and using the concept of lazyModules and the idea of feature modules.

Using LazyModules will load a module only if the router is reached . Here you can use guards to control using a service if your user is admin or just user. More info about guards.

Upvotes: 2

Related Questions