Até o momento está assim:
Então, tenho este serviço de Anti Guard.
import { Injectable } from '@angular/core';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { AuthenticationService } from '../servico/authentication/authentication.service';
@Injectable()
export class CanActivateAuthGuard implements CanActivate {
constructor(
private router: Router,
private authService: AuthenticationService
) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (this.authService.isLoggedIn()) {
return true;
}
this.router.navigate(['/authentication']);
return false;
}
}
Rota
import { Routes } from '@angular/router';
import { FullComponent } from './layouts/full/full.component';
import { AppBlankComponent } from './layouts/blank/blank.component';
export const AppRoutes: Routes =
[
{
path: '',
component: FullComponent,
children:
[
{
path: '',
loadChildren: './dashboards/dashboards.module#DashboardsModule'
/*pathMatch: 'full',
redirectTo: '/dashboards/dashboard1', */
},
{
path: 'configuracao',
loadChildren: './paginas/configuracao/configuracao.module#ConfiguracaoModule'
},
{
path: 'arquivo',
loadChildren: './paginas/arquivo/arquivo.module#ArquivoModule'
},
{
path: 'declaracao',
loadChildren: './paginas/declaracao/declaracao.module#DeclaracaoModule'
},
{
path: 'parametro',
loadChildren: './paginas/parametro/parametro.module#ParametroModule'
},
{
path: 'endereco',
loadChildren: './paginas/endereco/endereco.module#EnderecoModule'
},
{
path: 'contribuinte',
loadChildren: './paginas/banco/banco.module#BancoModule'
},
{
path: 'dashboard',
loadChildren: './dashboards/dashboards.module#DashboardsModule'
}
]
},
{
path: '',
component: AppBlankComponent,
children:
[
{
path: 'authentication',
loadChildren: './authentication/authentication.module#AuthenticationModule'
}
]
},
{
path: '**',
redirectTo: '404'
}
];
Não consegui implementar.