Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Last active December 28, 2021 22:38
Show Gist options
  • Save NyaGarcia/f39a4646ff383c4e7519ada41d04224c to your computer and use it in GitHub Desktop.
Save NyaGarcia/f39a4646ff383c4e7519ada41d04224c to your computer and use it in GitHub Desktop.
Implementing the register logic in the register page
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-register-page',
templateUrl: './register-page.component.html',
styleUrls: ['./register-page.component.css'],
})
export class RegisterPageComponent implements OnInit {
constructor(
private readonly authService: AuthService,
private readonly router: Router
) {}
ngOnInit(): void {}
register(data: LoginData) {
this.authService
.register(data)
.then(() => this.router.navigate(['/login']))
.catch((e) => console.log(e.message));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment