Created
November 30, 2021 14:48
-
-
Save NyaGarcia/298654cd9c7c93f1c8f2af4d8cce0ca6 to your computer and use it in GitHub Desktop.
Adding a logout method to the dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { AuthService } from '../../core/services/auth.service'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-dashboard', | |
templateUrl: './dashboard.component.html', | |
styleUrls: ['./dashboard.component.css'], | |
}) | |
export class DashboardComponent implements OnInit { | |
constructor(private authService: AuthService, private router: Router) {} | |
ngOnInit(): void {} | |
logout() { | |
this.authService | |
.logout() | |
.then(() => this.router.navigate(['/'])) | |
.catch((e) => console.log(e.message)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment