为了账号安全,请及时绑定邮箱和手机立即绑定

无法读取未定义的属性“已启用”

无法读取未定义的属性“已启用”

白衣非少年 2021-11-04 16:29:14
在代码中。我必须以反应形式设置控件的值。ngDoCheck() {   setControlValues();}ngChanges(changes: SimpleChanges): void {   setControlValues();}private setControlValues() {   try {   theForm.Controls['class'].setValue(myValue); //error happens here   // ...many controls   }   catch(e) {      console.log(e);   }}但是我得到了例外。无法在 eval (forms.js:4852) at(forms.js:4873) at eval(forms.js.4793) at Array.forEach() at FormGroup._forEachChild 处读取未定义的属性“已启用”..... .at FormControl.AbstractControl.updateValueAndValidity (forms.js: 3393)表格定义为theForm: FormGroup;constructor(private fb: FormBuilder) {    this.useForm = this.fb.group({    class: [null] });}我的 html 是:<texearea kendoYextArea     formControlName="class" required></textarea>更新:我发现库中的 forms.js 代码如下。 AbstractControl.prototype.updateValueAndValidty = function(opts) {    if(opts == void 0) { opts = {}; }    this._setInitialStatus();    if(this.enabled ) {        this._cancelExistingSubscription();
查看完整描述

1 回答

?
12345678_0001

TA贡献1802条经验 获得超5个赞

还是没有头绪。但如果我使用

 theForm.Controls['class'].patchValue(myValue)

然后错误消失了。


查看完整回答
反对 回复 2021-11-04
  • 1 回答
  • 0 关注
  • 164 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信