How to get FormArrayName when the FormArray is nested in another FormArray?

后端 未结 2 1715
悲&欢浪女
悲&欢浪女 2021-02-06 01:42

Refering to : https://angular.io/docs/ts/latest/api/forms/index/FormArrayName-directive.html, it is easy to get a FormArrayName :

HTML:

         


        
2条回答
  •  时光说笑
    2021-02-06 02:02

    I struggling same problem. And finaly solved it. Firstly we looking to main form array 'cities' structure.

    Which is the yellow highlited controls at image is first array control path. => cities And green highlited control is second array control. => sisterCities

        
    ...

    Proper way to access this second nested FormArray is accessing first control array after insert current cities index. And respectively sisterCities,control.

    let sisterCity of cities.controls[i].sisterCities.controls
    

提交回复
热议问题