Angular 4 remove required validator conditionally

后端 未结 10 1940
[愿得一人]
[愿得一人] 2021-02-01 01:26

In Angular 4 app I have a form model like this:

this.form = this._fb.group({
    title: [\'\', [Validators.required, Validators.minLength(3), Validators.maxLengt         


        
10条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 02:13

    Use empty array to remove all existing validators.

    this.frmFeasibility.controls['pop_name'].setValidators([]);
    this.frmFeasibility.controls['pop_name'].updateValueAndValidity();
    

提交回复
热议问题