Skip to content

Instantly share code, notes, and snippets.

@ganqqwerty
Created June 18, 2019 11:49
Show Gist options
  • Save ganqqwerty/a27c4c4a236c017e189e45342b9795a5 to your computer and use it in GitHub Desktop.
Save ganqqwerty/a27c4c4a236c017e189e45342b9795a5 to your computer and use it in GitHub Desktop.
this.myForm.get('myCheckbox').valueChanges
.subscribe(value => {
if(value) {
this.myForm.get('myEmailField').setValidators(this.emailValidators.concat(Validators.required))
} else {
this.myForm.get('myEmailField').setValidators(this.emailValidators);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment