import { Component, OnInit } from '@angular/core'; import { AuthenticationService } from 'src/app/shared/services/authentication.service'; import { AuthService } from 'src/app/shared/services/auth.service' import { Router } from '@angular/router'; @Component({ selector: 'app-logout', templateUrl: './logout.component.html', styleUrls: ['./logout.component.css'], providers: [AuthenticationService] }) export class LogoutComponent implements OnInit { constructor(private authentication: AuthenticationService, private auth: AuthService, private _router: Router) { } ngOnInit() { this.logout(); } logout() { this.authentication.logout() .then(() => { this.auth.logoutSuccess(); setTimeout(() => { this._router.navigate(['/']); }, 2500); }) .catch((err) => { console.log(err); }) } }