如何在angular2的数组中设置补丁值(更新嵌套值)?

how to set patch value (update the nested value ) in array in array in angular2?

我有一个像

这样的嵌套数组
permission": [
{
  "id": 2,
  "key": "creatBusinessPermission",
  "legend": "BusinessModule",
  "ischecked": false,
  "label": " Create Business Settings",
  "roles": [
    {
      "id": 1,
      "key": "self",
      "ischecked": false
    },
    {
      "id": 2,
      "key": "selfrole",
      "ischecked": false
    },
    {
      "id": 3,
      "key": "other",
      "ischecked": false
    },
    {
      "id": 4,
      "key": "All",
      "ischecked": false
    }
  ]
},
{
  "id": 3,
  "key": "editBusinessPermission",
  "legend": "BusinessModule",
  "ischecked": true,
  "label": " Edit Business Settings",
  "roles": [
    {
      "id": 1,
      "key": "self",
      "ischecked": false
    },
    {
      "id": 2,
      "key": "selfrole",
      "ischecked": false
    },
    {
      "id": 3,
      "key": "other",
      "ischecked": false
    },
    {
      "id": 4,
      "key": "All",
      "ischecked": false
    }
  ]
}]

对于上面的数组,我使用的是反应形式, 构建表单后,我有一个 onchange 权限函数,当调用该函数时,与权限相关的 ischecked 和 self ischecked 更改为 true,我完成的 pesrmission 被检查为 true perfect, 我正在努力做 is ** self ** ischecked as true,

这是我的代码

 (<FormArray>this.roleForm.controls['permission']).at(index).patchValue({
      ischecked : true
    }) This is works fine

我不知道该怎么做

(<FormArray>this.roleForm.controls['permission']).at(index).get('roles').at(1)..patchValue({
      ischecked : true
    }) this code giving error, Probebly I did n't no how to do

试试这个

let x = (<FormArray>this.roleForm.controls['permission']).at(index).get('roles')
let y =   (<FormControl>x.controls[0])

y.patchValue({
        ischecked: true
      })