代码之家  ›  专栏  ›  技术社区  ›  r2018

角度6反应形式验证器.minlength

  •  0
  • r2018  · 技术社区  · 6 年前

    ngOnInit() {
        const formControl = this.group.controls[this.config.name];
    
        // if (this.config.validation.required) {
        //  this.validators.push(Validators.required);
        //  formControl.setValidators([Validators.required]);
        // }
    
        if (this.config.validation.minLength) {
            this.validators.push(Validators.minLength(this.config.validation.minLength));
            formControl.setValidators([Validators.minLength(this.config.validation.minLength)]);
        }
    
        formControl.setValue(null);
        formControl.updateValueAndValidity();
    
        console.log(this.group.controls[this.config.name].validator(formControl));
        this.ready = true;
    
    
    }
    

    请注意:配置设置正在从JSON中读取

    1 回复  |  直到 6 年前
        1
  •  0
  •   r2018    6 年前

    在一些挖掘和断点设置之后,问题被发现在其他地方,当然,当我发布这个问题时,我的分析是错误的。