我試着與設置角料步進這裏如何跟進步驟:https://material.angular.io/components/stepper/overview角料步進:錯誤:無法找到名稱對照:「formArray」
我想有多個步驟,使一個簡單的單一形式我創造了這個:
<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
我真的已經盡力遵循的文件,但我不明白我需要做什麼來解決它......
感謝,酷和複雜:)所以我會嘗試和完全刪除formArray,formGroup所有這些東西,看看它的工作,將更新。 – Jas
刪除所有formGroup formArray formArrayName Ctrl和所有看起來工作。謝謝:)只是試圖按照例子... – Jas
很酷。快樂學習! – amal