Initially, the template login (login.component
) needs to be called first. Once the login is complete, then app.component
will be loaded.
Is it possible to achieve this? And if so, how can I do it?
Edited Question:
I am already using CanActivate. Apologies for my English as I am still learning. My objective is to...
have the bootstrap initiate app.component
first.
@Component({
selector: 'my-app',
template: `
<ul class="sidebar-menu">
<li class="header">Painel</li>
<li class="treeview">
<a href="#"><i class="fa fa-link"></i> <span>Loja</span>
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>
</a>
<ul class="treeview-menu">
<li><a routerLink="/dashboard">Dashboard</a></li>
</ul>
</li>
<li><a routerLink="/users"><i class="fa fa-book"></i> <span>User</span></a></li>
</ul>
<div class="content-wrapper">
<router-outlet></router-outlet>
</div>`,
})
export class AppComponent implements OnInit{}
To ensure that login.component
is called before app.component
, you need to implement a mechanism where the user must log in first before accessing any content from app.component
.
The menu will only be displayed if login.component
is part of a route, as the menu content will be rendered within
<router-outlet></router-outlet>
.