import { Component , OnInit } from '@angular/core' ; import { FormBuilder , FormGroup , Validators } from '@angular/forms' ; import { ToastrService } from 'ngx-toastr' ; import { RegisterModel } from 'src/app/models/registerModel' ; import { AuthService } from 'src/app/services/auth.service' ; import { LocalStorageService } from 'src/app/services/local-storage.service' ; @ Component ( { selector : 'app-register' , templateUrl : './register.component.html' , styleUrls : [ './register.component.css' ] } ) export class RegisterComponent implements OnInit { registerForm : FormGroup ; constructor ( private formBuilder , private authService , private toastrService , private localStorageService ) { } ngOnInit ( ) { this . createRegisterForm ( ) ; } createRegisterForm ( ) { this . registerForm = this . formBuilder . group ( { firstName : [ "" , Validators . required ] , lastName : [ "" , Validators . required ] , email : [ "" , Validators . required ] , password : [ "" , Validators . required ] } ) ; } register ( ) { if ( this . registerForm . valid ) { let registerModel = Object . assign ( { } , this . registerForm . value ) ; this . authService . register ( registerModel ) ; } else { this . toastrService . info ( "Lütfen tüm alanları doldurunuz" , "Bilgilendirme" ) ; } } }