📜  表单控件添加禁用和验证器 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:26.028000             🧑  作者: Mango

代码示例1
value: string;
isDisabled: boolean;
//isDisabled and value come from your dynamic data.  
fb: FormBuilder;
myGroup: FormGroup;

this.myGroup = fb.group({
   form_control_name: new FormControl({
      value: this.value,
      disabled: this.isDisabled,
      Validators.required)}
   );