Ashley Albert has four years of professional experience, beginning with a role as Data Analyst at Convergys in 2018. Ashley then moved to Upwork as a Data Scientist in 2020, followed by Data Development Specialist at DataGardener in 2021, and most recently Data Partnerships Lead at BIScience in 2021.
import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router } from '@angular/router';
import { AuthService } from 'src/app/services/auth.service';
import { UserService } from 'src/app/services/user.service';
import { User } from 'src/app/models/user';
@Component({
selector: 'app-register',
templateUrl: './register.component.html',
styleUrls: ['./register.component.css']
})
export class RegisterComponent implements OnInit {
registerForm: FormGroup;
errorMessage: string;
constructor(private formBuilder: FormBuilder,
private authService: AuthService,
private userService: UserService,
private router: Router) { }
ngOnInit() {
this.initForm();
}
initForm() {
this.registerForm = this.formBuilder.group({
email: ['', [Validators.required, Validators.email]],
password: ['', [Validators.required, Validators.pattern(/[0-9a-zA-Z]{6,}/)]]
});
}
onSubmit() {
const email = this.registerForm.get('email').value;
const password = this.registerForm.get('password').value;
this.authService.createNewUser(email, password).then(
() => {
const user = new User(email);
this.userService.createNewUser(user);
this.router.navigate(['/books']);
},
(error) => {
this.errorMessage = error;
}
);
}
}
Sign up to view 0 direct reports
Get started