Created
November 9, 2020 21:54
-
-
Save blogcacanid/089da54be8e5ba35cd68583e3720a615 to your computer and use it in GitHub Desktop.
register.component.ts Authentication JWT Angular 9 Lumen 7
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 '../_services/auth.service'; | |
@Component({ | |
selector: 'app-register', | |
templateUrl: './register.component.html', | |
styleUrls: ['./register.component.css'] | |
}) | |
export class RegisterComponent implements OnInit { | |
form: any = {}; | |
isSuccessful = false; | |
isSignUpFailed = false; | |
errorMessage = ''; | |
constructor(private authService: AuthService) { } | |
ngOnInit(): void { | |
} | |
onSubmit(): void { | |
this.authService.register(this.form).subscribe( | |
data => { | |
console.log(data); | |
this.isSuccessful = true; | |
this.isSignUpFailed = false; | |
}, | |
err => { | |
this.errorMessage = err.error.message; | |
this.isSignUpFailed = true; | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment