小编Evo*_*kee的帖子

错误错误:找不到带有路径的控件

我是Angular的新手,并尝试从以下示例扩展示例代码:Angular 4 Form FormArray添加一个按钮以添加或删除表单输入行

如果在下拉菜单中选择了某个选项,则该选项的新选项应可表示。我到此为止没有问题,但是为那些“较低层选项”实现formControlName标记使我出错:

ContentComponent.html:56错误错误:找不到路径为'inhalt-> 0-> optionsKey'(…)的控件

.html中的确切行是:(输入formControlName =“ optionsKey”)

我在其他线程(Angular 2形式“找不到带有路径的控件”)或(Angular 2反应形式:找不到带有路径的控件)或(错误:找不到带有路径的控件:'x'angular 2)中寻找了那些错误,但是它们的问题是基于没有FormBuilder的ReactiveForm-Components创建的。我使用Formbuilder创建了我的所有ReactiveForm-Components,您将在我的代码中看到它们。

我可能错过了某件事还是做错了方向?

content.html

<h3 class="page-header">Formular-Abschnitt hinzufügen</h3>
<button type="button" (click)="addNewFormControl()" class="btn btn-primary">Neues Formularelement</button><br>
<form [formGroup]="formContent">
  <div>
    <label>Bezeichnung des Abschnittes</label>
    <input formControlName="absatz">
  </div>
  <div formArrayName="inhalt">

    <!--
    In the template we are iterating this formarray,
        and that is just the path to the formarray, which is:

        invoiceForm.controls.itemRows.controls

        'invoiceForm' being the complete form object, 'controls' being the content of the form …
Run Code Online (Sandbox Code Playgroud)

typescript angular angular-reactive-forms angular-forms

2
推荐指数
1
解决办法
5370
查看次数