Last active
December 28, 2021 22:18
-
-
Save NyaGarcia/95e7be2a61090ac15f7a92ad3505e729 to your computer and use it in GitHub Desktop.
Adding a login method
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 'src/app/core/services/auth.service'; | |
import { LoginData } from 'src/app/core/interfaces/login-data.interface'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-login-page', | |
templateUrl: './login-page.component.html', | |
styleUrls: ['./login-page.component.css'], | |
}) | |
export class LoginPageComponent implements OnInit { | |
constructor( | |
private readonly authService: AuthService, | |
private readonly router: Router | |
) {} | |
ngOnInit(): void {} | |
login(loginData: LoginData) { | |
this.authService | |
.login(loginData) | |
.then(() => this.router.navigate(['/dashboard'])) | |
.catch((e) => console.log(e.message)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment