在代码中。我必须以反应形式设置控件的值。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 回答
![?](http://img1.sycdn.imooc.com/54584f850001c0bc02200220-100-100.jpg)
12345678_0001
TA贡献1802条经验 获得超5个赞
还是没有头绪。但如果我使用
theForm.Controls['class'].patchValue(myValue)
然后错误消失了。
添加回答
举报
0/150
提交
取消