【问题标题】:Accesing to Controls of Nested Form Array访问嵌套 Formarray 的控件
【发布时间】:2021-10-16 15:06:59
【问题描述】:

我想引用下图中黄色的控件,谁能帮助我如何获取该引用,以便我可以推送实时数据。

【问题讨论】:

  • 到目前为止你尝试了什么?
  • 我能够使用下面的代码(this.contracttemplateform.get('contractproperties')).controls 获得引用直到上面的formarray,但我无法获得对下一个控件的引用
  • const test = (((this.contracttemplateform.get('contractproperties')).controls[0]).controls['templateTCText']);
  • 当我们打印控件[0]时出现错误,例如 can't read property controls of null

标签: angular nested-forms reactive formarray


【解决方案1】:

你可以通过这个来获得这个值

this.formArray.get('templateTCText').get('0')

formArray 是您在问题中显示的变量

【讨论】:

  • 我需要的Json结构如下 -------------- contracttemplateproperties [ { name:'cat', title:'pet type', templatetctext [ { 'requiresspecialbid':'true', 'largetext':'关于猫的描述' }, { 'requiresspecialbid':'false', 'largetext':'关于狗的描述}] } ] ---------- ----------------- //fb 表单生成器 contracttemplateform=thi.fb.group ({ contracttemplateproperties=this.fb.array([]) }) ------ --------------------如何形成json结构??????
  • this.formArray.get('templateTCText').get('0') this 不起作用,因为它存在于另一个 formarray 下
猜你喜欢
  • 1970-01-01
  • 2019-08-03
  • 1970-01-01
  • 2021-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-02
  • 2019-04-21
相关资源
最近更新 更多