在代码中。我必须以反应形式设置控件的值。
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();
12345678_0001
相关分类