【发布时间】:2017-11-27 15:34:18
【问题描述】:
尝试删除我添加到表单的控件
我尝试过this.*FormArray*.splice,但它无法编译。说FormArray has no method splice。然后我尝试了removeAt(),但是当我运行代码时,错误提示为removeAt is not a method。一次编译失败,下一次运行时失败。
我想从控件数组中删除一个控件。
【问题讨论】:
-
如果你想从
FormArray中删除特定的FormGroup,你可以这样做(指定索引):removeAt(<index>)。如果要从每个 FormGroup 中删除特定控件,则必须遍历 FormArray。 -
@developer033 `[FormGroup, FormGroup] - 什么是 removeAt 被调用?
-
See this tutorial。正如我所说,它有一个 PLUNKER,你可以看到如何删除它。
-
这应该写成答案:this.*FormArray*.removeAt(
) -
在动态删除表单控件后,我在提交表单时收到错误“TypeError: Cannot read property 'updateOn' of null”。有没有人解决这个问题? @菲尔
标签: angular angular2-forms angular-reactive-forms