Skip to content

Instantly share code, notes, and snippets.

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