简体   繁体   English

以角度2反应形式动态删除表单控件

[英]remove form control dynamically in angular 2 reactive forms

Try to remove a control that I add to a form 尝试删除我添加到表单的控件

I have tried this.*FormArray*.splice but it doesn't compile. 我试过this.*FormArray*.splice但它没有编译。 Saying that FormArray has no method splice . FormArray has no method splice Then I tried removeAt() but then when I run the code the error says, removeAt is not a method . 然后我尝试了removeAt()但是当我运行错误的代码时, removeAt is not a method One compile time fails, the next runtime fails. 一个编译时失败,下一个运行时失败。

I want to remove a control from an array of controls. 我想从一组控件中删除一个控件。

removeAt() is a method on the FormArray namespace, but not a ES5-7 method. removeAt()是FormArray命名空间上的方法,但不是ES5-7方法。

(<FormArray>items).removeAt(idx) forced the array to become a Typescript FormArray object which opened up the methods. (<FormArray>items).removeAt(idx)强制数组成为打开方法的Typescript FormArray对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM