我有一个形式使用的反应形式的方法。形式创建如下在我的哈巴狗:
form([formGroup]='form', novalidate='', (ngSubmit)='postSurvey(form.value, form.valid)')
除了在 javascript 部分中尝试更改表单(即 FormArray)之外,一切都正常。我得到以下错误:
EXCEPTION: Error in http://localhost:8080/app/components/fillForm.template.html:0:326 caused by: control.registerOnChange is not a function
core.umd.js:3497 TypeError: control.registerOnChange is not a function
at setUpControl (http://localhost:8080/node_modules/@angular/forms/bundles/forms.umd.js:1634:17)
at eval (http://localhost:8080/node_modules/@angular/forms/bundles/forms.umd.js:4752:25)
at Array.forEach (native)
at FormGroupDirective._updateDomValue (http://localhost:8080/node_modules/@angular/forms/bundles/forms.umd.js:4747:29)
at FormGroupDirective.ngOnChanges (http://localhost:8080/node_modules/@angular/forms/bundles/forms.umd.js:4616:22)
at Wrapper_FormGroupDirective.ngDoCheck (/ReactiveFormsModule/FormGroupDirective/wrapper.ngfactory.js:30:18)
at View_FillFormComponent2.detectChangesInternal (/AppModule/FillFormComponent/component.ngfactory.js:275:32)
at View_FillFormComponent2.AppView.detectChanges (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:12592:18)
at View_FillFormComponent2.DebugAppView.detectChanges (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:12739:48)
at ViewContainer.detectChangesInNestedViews (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:12850:41)
at CompiledTemplate.proxyViewClass.View_FillFormComponent0.detectChangesInternal (/AppModule/FillFormComponent/component.ngfactory.js:64:14)
at CompiledTemplate.proxyViewClass.AppView.detectChanges (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:12592:18)
at CompiledTemplate.proxyViewClass.DebugAppView.detectChanges (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:12739:48)
at CompiledTemplate.proxyViewClass.AppView.internalDetectChanges (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:12577:22)
at CompiledTemplate.proxyViewClass.View_FillFormComponent_Host0.detectChangesInternal (/AppModule/FillFormComponent/host.ngfactory.js:29:19)
我的代码来改变形式是相当复杂的,我不能简化它或复制它在一个柱塞。除了直接找到解决方案(这太难了,因为细节太少) ,我还想知道这个错误意味着什么?是什么导致了这个错误。
我已经发现错误发生在我的 HTML 的 [formGroup]='form'。
任何建议都会有帮助。
更新 我已经在角度 github 给你上提交了一个问题,并且已经提出了一个修复方案 给你重现这个问题的活塞是 < a href = “ http://next.plnkr.co/edit/vh1HCo2WrwNgr95G? open = lib% 2Fapp.ts & amp; deferRun = 1”rel = “ noReferrer”> 在这里