我已经输入了电话号码,如果电话号码有效,那么表格将打开5个完整的输入项。
this.contactUsForm = this.formBuilder.group({
contact_number: ['', Validators.compose([Validators.required, Validators.pattern(this.globalService.pattern)]), {disabled: true}],
});
如何添加更多控制而不影响我的contact_number值。我只想添加更多这样的控件:
this.contactUsForm = this.formBuilder.group({
contact_number: ['', Validators.compose([Validators.required, Validators.pattern(this.globalService.pattern)]), {disabled: true}],
verification_code: ['', Validators.required]
firstname: ['', Validators.required]
lastname: ['', Validators.required]
});
contact_number成功后我尝试这样做:
this.contactUsForm.addControl('verification_code', new FormControl('', Validators.required));
但是我遇到了错误 ERROR TypeError:v不是函数
答案 0 :(得分:0)
谢谢大家的评论。出现错误是因为我正在这样做
this.contactUsForm = this.formBuilder.group({
contact_number: ['', Validators.compose([Validators.required, Validators.pattern(this.globalService.pattern)]), {disabled: true}],
});
它在删除{disabled: true}