UNPKG

mean-guide-frontend

Version:

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

33 lines (29 loc) 864 B
import { Component, OnDestroy, OnInit } from '@angular/core'; import { NgForm } from '@angular/forms'; import { Subscription } from 'rxjs'; import { AuthService } from '../auth.service'; @Component({ templateUrl: './signup.component.html', styleUrls: ['./signup.component.css'], }) export class SignupComponent implements OnInit, OnDestroy { private authStatusSub: Subscription; constructor(public authService: AuthService) {} ngOnDestroy(): void { this.authStatusSub.unsubscribe(); } ngOnInit(): void { this.authStatusSub = this.authService .getAuthStatusListener() .subscribe((status) => (this.isLoading = false)); } isLoading = false; onSignup(form: NgForm) { console.log(form.value); if (form.invalid) { return; } this.isLoading = true; this.authService.createUser({ ...form.value }); } }