angular form control validation code example
Example 1: formgroup check if valid
form: FormGroup;
onSubmit(){
//checks if form is valid
if( this.form.valid){
//more code here
}
}
Example 2: get formcontrol value
this.loginForm = new FormGroup({
'email': new FormControl('', { validators: [Validators.required] })
});
// get like this
const { email } = this.loginForm.value;