I have a login page and after login in I am redirecting to a dashboard. The dashboard has some children pages also. I need that when you be logged in and click in the logo I be redirected to the dashboard and if I am not logged in I be redirected to the login page. Here is an example of my code:
navbar.component.html
<mat-toolbar>
<h1>
<a routerLink="/">
<img src="../image.jpg"/>
</a>
</h1>
</mat-toolbar>
routing.module.ts
.
.
.
const routes: Routes = [
{
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{
path: 'login',
component: ClientLayoutComponent,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [DashboardGuard],
},
{
path: 'account',
component: AccountComponent
},
{ path: 'Blog', component: BlogComponent },
],
},
},
];
The steps are so clear:
- If I am not logged in, when I click in the logo it have to go to login page or,
- If I am logged in, when I click in the logo it have to go to dashboard page
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…