Angular 4 remove required validator conditionally

Source: https://stackoverflow.com/questions/46488078/angular-4-remove-required-validator-conditionally

if you want to add validation try this one.
saveDraft() {
   this.form.get('title').setValidators([Validators.required, Validators.minLength(3)]);
   this.form.get('title').updateValueAndValidity();
}
if you want to remove validators try this one.
saveDraft() {
 this.form.get('title').clearValidators();
 this.form.get('title').updateValueAndValidity();
}

Không có nhận xét nào:

URL parameters with React Router

 https://ui.dev/react-router-url-parameters If you're reading this, you're probably familiar with the idea of function parameters. T...