In app.component.html :
<router-outlet></router-outlet>
Then create MainComponent (main.component.ts) and put all your main application layout in main.component.html :
<div class="right_col" role="main"> <router-outlet></router-outlet> </div>
This component will be the parent for each of your regular application components.
Then in your LoginComponent put a different layout without the router exiting, for example:
<div class="login-wrapper"> <div class="login"> ... your login layout </div> </div>
Then change your routing like this:
const appRoutes: Routes = [ {path: 'login', component: LoginComponent}, {path: '', component: MainComponent, redirectTo: '/dashboard', pathMatch: 'full', children: [ { path: 'alert/:id', component: AlertDetailComponent }, { path: 'alerts', component: AlertsComponent }, { path: 'dashboard', component: EriskDashboardComponent } ]}];
So, MainComponent will contain all reusable layouts and application structure for any child component, while LoginComponent is independent and has its own layout.
cutoffurmind
source share