【发布时间】:2018-03-23 04:26:45
【问题描述】:
我尝试在此处跟进如何设置角度材料步进器的步骤:https://material.angular.io/components/stepper/overview
我想要一个包含多个步骤的简单表单,所以我创建了这个:
<form [formGroup]="formGroup">
<mat-horizontal-stepper formArrayName="formArray" linear>
<mat-step formGroupName="0" [stepControl]="formArray.get([0])">
<div>
<button mat-button matStepperNext type="button">Next</button>
</div>
</mat-step>
<mat-step formGroupName="1" [stepControl]="formArray.get([1])">
<div>
<button mat-button matStepperPrevious type="button">Back</button>
<button mat-button matStepperNext type="button">Next</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</form>
我进入我的控制台:
ERROR Error: Cannot find control with name: 'formArray'
at _throwError (forms.es5.js:1918)
at setUpFormContainer (forms.es5.js:1891)
at FormGroupDirective.webpackJsonp.../../../forms/@angular/forms.es5.js.FormGroupDirective.addFormArray (forms.es5.js:4849)
at FormArrayName.webpackJsonp.../../../forms/@angular/forms.es5.js.FormArrayName.ngOnInit (forms.es5.js:5134)
at checkAndUpdateDirectiveInline (core.es5.js:10856)
at checkAndUpdateNodeInline (core.es5.js:12364)
at checkAndUpdateNode (core.es5.js:12303)
at debugCheckAndUpdateNode (core.es5.js:13167)
at debugCheckDirectivesFn (core.es5.js:13108)
at Object.eval [as updateDirectives] (MystepperComponent.htm
我的测试的完整源代码在这里:angular stepper test example on github
我确实尽了最大努力遵循文档,但我不明白我需要做些什么来修复它......
【问题讨论】: