Sign-in Form - Angular Implementation

   let url = window.location.href;

    if(url.includes('localhost')) {
      this.loginForm.patchValue({
        email : 'test@gmail.com'
        password:'password'
      })
    }
import { FormBuilderFormGroupValidators } from '@angular/forms';
 loginFormFormGroup;
constructor(private formBuilderFormBuilder,){
    this.initForm();
}
 
initForm(){

this.loginForm = this.formBuilder.group({
      email: ['',[]], //Validators.required, Validators.minLength(5),Validators.pattern(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/i)
      phone:['',[]], //[Validators.required, Validators.pattern(/^[0-9]*$/),Validators.maxLength(17),Validators.maxLength(7)]
      password: ['', []] //Validators.required
    });

}

get f() {
    return this.loginForm.controls;
  }

Comments

Popular posts from this blog

Become a Expert + Secret of Success -- ii

Change Detection

without writing media queries How to make responsive component