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