Polo
Polo

Reputation: 35

Angular 4 app with admin page, two apps on one server

I'm working on an web-app which needs a dashboard page, so I don't know if its better to do two different apps and use them separately, or to do one single app with the dashboard inside of it.

My problem with the second option is that I have some components in common, and some components just have little changes.

In case of the first option: How can I have two apps running on one server?


I think this is completely wrong, but its possible to do something like this?

<body>
   <app-root *ngIf="!adminMode"></app-root>
   <app-root2 *ngIf="adminMode"></app-root>
</body>

Upvotes: 0

Views: 380

Answers (2)

Vuu
Vuu

Reputation: 1

In this case, you should develop a single app with the admin dashboard/features built in. You only need one root container for your app in the index.html. Don't do multiple tags like you have now.

I assume the admin has to authenticate to see the admin features right? Maybe create a route called /admin that displays the dashboard with the login form? Once authenticated, you can set adminMode flag to true? I hope this helps.

Upvotes: 0

DeborahK
DeborahK

Reputation: 60518

You probably want one app-root component, but that component can have multiple components nested within it.

Index.html

<body>
   <app-root></app-root>
</body>

App Component Template

   <shell *ngIf="!adminMode"></shell>
   <admin-shell *ngIf="adminMode"></admin-shell>

Upvotes: 1

Related Questions